From 42a010a8a07991abf59aef00355fd832fe741be7 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sat, 1 Mar 2025 09:33:47 +0100 Subject: [PATCH 1/9] Replace DOTNET_SKIP_FIRST_TIME_EXPERIENCE with DOTNET_NOLOGO (#1692) * Replace DOTNET_SKIP_FIRST_TIME_EXPERIENCE with DOTNET_NOLOGO * Fix broken build on .NET SDK v9.0.200 --- .editorconfig | 8 ++++++++ .github/workflows/build.yml | 14 +++++++------- Directory.Build.props | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 37fda299fb..2e5c1061b9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -113,6 +113,12 @@ csharp_style_expression_bodied_properties = true:silent # IDE0025: Use expression body for properties dotnet_diagnostic.IDE0025.severity = silent +# Member preferences (these analyzers are unreliable) +# IDE0051: Remove unused private member +dotnet_diagnostic.IDE0051.severity = silent +# IDE0052: Remove unread private member +dotnet_diagnostic.IDE0052.severity = silent + # Code-block preferences csharp_prefer_braces = true:silent # IDE0011: Add braces @@ -142,11 +148,13 @@ dotnet_diagnostic.IDE0047.severity = silent # IDE0048: Add parentheses for clarity dotnet_diagnostic.IDE0048.severity = silent +# Switch preferences # IDE0010: Add missing cases to switch statement dotnet_diagnostic.IDE0010.severity = silent # IDE0072: Add missing cases to switch expression dotnet_diagnostic.IDE0072.severity = silent +# Null check preferences # IDE0029: Null check can be simplified dotnet_diagnostic.IDE0029.severity = silent # IDE0030: Null check can be simplified diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d16479acd2..720b7fe6d8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ concurrency: cancel-in-progress: true env: - DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_NOLOGO: true DOTNET_CLI_TELEMETRY_OPTOUT: true jobs: @@ -47,8 +47,8 @@ jobs: with: # Block buggy release from February 11, 2025 dotnet-version: | - 8.0.309 - 9.0.103 + 8.0.* + 9.0.* - name: Show installed versions shell: pwsh run: | @@ -166,8 +166,8 @@ jobs: with: # Block buggy release from February 11, 2025 dotnet-version: | - 8.0.309 - 9.0.103 + 8.0.* + 9.0.* - name: Git checkout uses: actions/checkout@v4 - name: Restore tools @@ -222,8 +222,8 @@ jobs: with: # Block buggy release from February 11, 2025 dotnet-version: | - 8.0.309 - 9.0.103 + 8.0.* + 9.0.* - name: Git checkout uses: actions/checkout@v4 with: diff --git a/Directory.Build.props b/Directory.Build.props index eeaaba8d16..7adc228bff 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -22,7 +22,7 @@ Taking the suggestion TODAY produces List, but the spec doesn't require that, so the compiler may change it over time. As a result, callers that cast back to List will face a breaking change. --> - IDE0028;IDE0300;IDE0301;IDE0302;IDE0303;IDE0304;IDE0305 + IDE0028;IDE0300;IDE0301;IDE0302;IDE0303;IDE0304;IDE0305;IDE0306 $(NoWarn);$(UseCollectionExpressionRules) From 32b26244893ea976c500054da3a3f8126f012c85 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 11:36:38 +0100 Subject: [PATCH 2/9] Update FluentAssertions (#1693) * Update Resharper * Update FluentAssertions package * Remove ShouldHaveCount * Remove ShouldNotBeEmpty * Remove ShouldNotBeNullOrEmpty * Remove ShouldOnlyContainKeys * Remove ShouldContainKey * Remove ShouldNotBeNull and redundant With calls --- .config/dotnet-tools.json | 2 +- package-versions.props | 2 +- .../AtomicOperations/AtomicOperationsTests.cs | 78 ++-- .../QueryStrings/FilterTests.cs | 134 +++--- .../QueryStrings/IncludeTests.cs | 66 +-- .../QueryStrings/PaginationTests.cs | 2 +- .../QueryStrings/SortTests.cs | 40 +- .../QueryStrings/SparseFieldSets.cs | 92 ++-- .../AddToToManyRelationshipTests.cs | 6 +- .../Relationships/FetchRelationshipTests.cs | 20 +- .../RemoveFromToManyRelationshipTests.cs | 20 +- .../ReplaceToManyRelationshipTests.cs | 40 +- .../UpdateToOneRelationshipTests.cs | 122 +++--- .../Resources/CreateResourceTests.cs | 122 +++--- .../Resources/DeleteResourceTests.cs | 14 +- .../ReadWrite/Resources/FetchResourceTests.cs | 86 ++-- .../Resources/UpdateResourceTests.cs | 68 +-- .../Sql/SubQueryInJoinTests.cs | 22 +- .../ServiceDiscoveryFacadeTests.cs | 7 +- .../Archiving/ArchiveTests.cs | 78 ++-- ...tomConstrainedOperationsControllerTests.cs | 14 +- ...ultConstrainedOperationsControllerTests.cs | 12 +- .../Creating/AtomicCreateResourceTests.cs | 159 ++++--- ...reateResourceWithClientGeneratedIdTests.cs | 54 +-- ...eateResourceWithToManyRelationshipTests.cs | 90 ++-- ...reateResourceWithToOneRelationshipTests.cs | 100 ++--- .../Deleting/AtomicDeleteResourceTests.cs | 48 +-- .../Links/AtomicAbsoluteLinksTests.cs | 32 +- .../AtomicRelativeLinksWithNamespaceTests.cs | 30 +- .../LocalIds/AtomicLocalIdTests.cs | 284 ++++++------ .../Meta/AtomicResourceMetaTests.cs | 22 +- .../Meta/AtomicResponseMetaTests.cs | 20 +- .../Mixed/AtomicLoggingTests.cs | 6 +- .../Mixed/AtomicRequestBodyTests.cs | 26 +- .../Mixed/MaximumOperationsPerRequestTests.cs | 6 +- .../AtomicModelStateValidationTests.cs | 40 +- .../QueryStrings/AtomicQueryStringTests.cs | 30 +- ...micSerializationResourceDefinitionTests.cs | 36 +- ...icSparseFieldSetResourceDefinitionTests.cs | 20 +- .../Transactions/AtomicRollbackTests.cs | 8 +- .../AtomicTransactionConsistencyTests.cs | 12 +- .../AtomicAddToToManyRelationshipTests.cs | 118 ++--- ...AtomicRemoveFromToManyRelationshipTests.cs | 116 ++--- .../AtomicReplaceToManyRelationshipTests.cs | 124 +++--- .../AtomicUpdateToOneRelationshipTests.cs | 128 +++--- .../AtomicReplaceToManyRelationshipTests.cs | 72 ++-- .../Resources/AtomicUpdateResourceTests.cs | 170 ++++---- .../AtomicUpdateToOneRelationshipTests.cs | 82 ++-- .../Scopes/ScopeOperationsTests.cs | 36 +- .../Authorization/Scopes/ScopeReadTests.cs | 58 +-- .../Authorization/Scopes/ScopeWriteTests.cs | 40 +- .../IntegrationTests/Blobs/BlobTests.cs | 38 +- .../CompositeKeys/CompositeKeyTests.cs | 24 +- .../ContentNegotiation/AcceptHeaderTests.cs | 22 +- .../ContentTypeHeaderTests.cs | 74 ++-- .../CustomExtensionsAcceptHeaderTests.cs | 10 +- .../CustomExtensionsContentTypeTests.cs | 34 +- .../ActionResultTests.cs | 12 +- .../ApiControllerAttributeLogTests.cs | 2 +- .../ApiControllerAttributeTests.cs | 10 +- .../CustomRoutes/CustomRouteTests.cs | 26 +- .../EagerLoading/EagerLoadingTests.cs | 82 ++-- .../ExceptionHandlerTests.cs | 20 +- .../HostingInIIS/HostingTests.cs | 44 +- .../IdObfuscation/IdObfuscationTests.cs | 38 +- .../ModelState/ModelStateValidationTests.cs | 58 +-- .../ModelState/NoModelStateValidationTests.cs | 6 +- .../RequestBody/WorkflowTests.cs | 10 +- .../Links/AbsoluteLinksWithNamespaceTests.cs | 110 ++--- .../AbsoluteLinksWithoutNamespaceTests.cs | 110 ++--- .../Links/DocumentDescriptionLinkTests.cs | 6 +- .../Links/LinkInclusionIncludeTests.cs | 10 +- .../Links/LinkInclusionTests.cs | 54 +-- .../Links/RelativeLinksWithNamespaceTests.cs | 110 ++--- .../RelativeLinksWithoutNamespaceTests.cs | 110 ++--- .../Meta/ResourceMetaTests.cs | 12 +- .../FireForgetTests.Group.cs | 30 +- .../FireForgetTests.User.cs | 38 +- .../FireAndForgetDelivery/FireForgetTests.cs | 6 +- .../OutboxTests.Group.cs | 30 +- .../OutboxTests.User.cs | 38 +- .../TransactionalOutboxPattern/OutboxTests.cs | 2 +- .../MultiTenancy/MultiTenancyTests.cs | 74 ++-- .../NamingConventions/KebabCasingTests.cs | 47 +- .../NamingConventions/PascalCasingTests.cs | 49 +-- .../NonJsonApiControllerTests.cs | 12 +- .../IsUpperCaseFilterParseTests.cs | 4 +- .../IsUpperCase/IsUpperCaseFilterTests.cs | 8 +- .../StringLength/LengthFilterParseTests.cs | 4 +- .../StringLength/LengthFilterTests.cs | 8 +- .../StringLength/LengthSortParseTests.cs | 4 +- .../StringLength/LengthSortTests.cs | 8 +- .../Sum/SumFilterParseTests.cs | 4 +- .../CustomFunctions/Sum/SumFilterTests.cs | 8 +- .../TimeOffset/TimeOffsetTests.cs | 24 +- .../Filtering/FilterDataTypeTests.cs | 50 ++- .../Filtering/FilterDepthTests.cs | 48 +-- .../Filtering/FilterOperatorTests.cs | 104 +++-- .../QueryStrings/Filtering/FilterTests.cs | 20 +- .../QueryStrings/Includes/IncludeTests.cs | 310 ++++++------- .../PaginationWithTotalCountTests.cs | 78 ++-- .../PaginationWithoutTotalCountTests.cs | 16 +- .../Pagination/RangeValidationTests.cs | 12 +- .../RangeValidationWithMaximumTests.cs | 12 +- .../QueryStrings/QueryStringTests.cs | 8 +- .../SerializerIgnoreConditionTests.cs | 12 +- .../QueryStrings/Sorting/SortTests.cs | 54 +-- .../SparseFieldSets/SparseFieldSetTests.cs | 344 +++++++-------- .../ReadWrite/Creating/CreateResourceTests.cs | 166 +++---- ...reateResourceWithClientGeneratedIdTests.cs | 62 +-- ...eateResourceWithToManyRelationshipTests.cs | 136 +++--- ...reateResourceWithToOneRelationshipTests.cs | 132 +++--- .../ReadWrite/Deleting/DeleteResourceTests.cs | 6 +- .../Fetching/FetchRelationshipTests.cs | 12 +- .../ReadWrite/Fetching/FetchResourceTests.cs | 76 ++-- .../AddToToManyRelationshipTests.cs | 82 ++-- .../RemoveFromToManyRelationshipTests.cs | 94 ++-- .../ReplaceToManyRelationshipTests.cs | 74 ++-- .../UpdateToOneRelationshipTests.cs | 66 +-- .../ReplaceToManyRelationshipTests.cs | 120 +++--- .../Updating/Resources/UpdateResourceTests.cs | 182 ++++---- .../Resources/UpdateToOneRelationshipTests.cs | 108 ++--- .../DefaultBehaviorTests.cs | 18 +- .../ResourceInjectionTests.cs | 46 +- .../Reading/ResourceDefinitionReadTests.cs | 72 ++-- .../ResourceDefinitionSerializationTests.cs | 98 ++--- .../AtomicOperationTests.cs | 12 +- .../ResourceInheritanceChangeTrackerTests.cs | 4 +- .../ResourceInheritanceReadTests.cs | 406 +++++++++--------- .../ResourceInheritanceWriteTests.cs | 176 ++++---- .../ResourceTypeCaptureStore.cs | 7 +- .../DisableQueryStringTests.cs | 14 +- .../NoRelationshipsControllerTests.cs | 12 +- .../ReadOnlyControllerTests.cs | 12 +- .../WriteOnlyControllerTests.cs | 10 +- .../Serialization/ETagTests.cs | 28 +- .../SoftDeletion/SoftDeletionTests.cs | 52 +-- .../ZeroKeys/EmptyGuidAsKeyTests.cs | 42 +- .../ZeroKeys/WhiteSpaceAsKeyTests.cs | 42 +- .../ZeroKeys/ZeroAsKeyTests.cs | 48 +-- .../UnitTests/Links/LinkInclusionTests.cs | 25 +- .../Middleware/JsonApiMiddlewareTests.cs | 7 +- .../ModelStateValidationTests.cs | 8 +- .../QueryStringParameters/FilterParseTests.cs | 8 +- .../IncludeParseTests.cs | 4 +- .../LegacyFilterParseTests.cs | 9 +- .../PaginationParseTests.cs | 8 +- .../QueryStringParameters/SortParseTests.cs | 8 +- .../SparseFieldSetParseTests.cs | 8 +- .../CreateSortExpressionFromLambdaTests.cs | 21 +- .../ResourceGraph/HasManyAttributeTests.cs | 13 +- .../ResourceGraphBuilderTests.cs | 6 +- .../ResourceObjectConverterTests.cs | 22 +- .../SourcePointerInExceptionTests.cs | 9 +- .../Serialization/InputConversionTests.cs | 9 +- .../Response/ResponseModelAdapterTests.cs | 4 +- test/MultiDbContextTests/ResourceTests.cs | 8 +- test/NoEntityFrameworkTests/PersonTests.cs | 32 +- test/NoEntityFrameworkTests/TagTests.cs | 34 +- test/NoEntityFrameworkTests/TodoItemTests.cs | 42 +- .../FluentAssertionsExtensions.cs | 49 +++ .../NullabilityAssertionExtensions.cs | 62 --- .../ResourceDescriptorAssemblyCacheTests.cs | 5 +- test/UnitTests/Graph/TypeLocatorTests.cs | 5 +- .../ResourceConstructionExpressionTests.cs | 3 +- 165 files changed, 4158 insertions(+), 4178 deletions(-) create mode 100644 test/TestBuildingBlocks/FluentAssertionsExtensions.cs delete mode 100644 test/TestBuildingBlocks/NullabilityAssertionExtensions.cs diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 4ae453e0c4..c1d943c0d0 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "jetbrains.resharper.globaltools": { - "version": "2024.3.5", + "version": "2024.3.6", "commands": [ "jb" ], diff --git a/package-versions.props b/package-versions.props index 2a26bd7b7a..e7c32c98fa 100644 --- a/package-versions.props +++ b/package-versions.props @@ -11,7 +11,7 @@ 4.12.* 6.0.* 2.1.* - 7.0.* + 7.2.* 2.4.* 2.0.* 9.0.* diff --git a/test/DapperTests/IntegrationTests/AtomicOperations/AtomicOperationsTests.cs b/test/DapperTests/IntegrationTests/AtomicOperations/AtomicOperationsTests.cs index bec6919496..64acaaa57f 100644 --- a/test/DapperTests/IntegrationTests/AtomicOperations/AtomicOperationsTests.cs +++ b/test/DapperTests/IntegrationTests/AtomicOperations/AtomicOperationsTests.cs @@ -168,20 +168,20 @@ public async Task Can_use_multiple_operations() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(7); + responseDocument.Results.Should().HaveCount(7); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("people")); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("people")); - responseDocument.Results[2].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("tags")); - responseDocument.Results[3].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("todoItems")); + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("people"); + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("people"); + responseDocument.Results[2].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("tags"); + responseDocument.Results[3].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("todoItems"); responseDocument.Results[4].Data.Value.Should().BeNull(); - responseDocument.Results[5].Data.SingleValue.ShouldNotBeNull().With(resource => resource.Type.Should().Be("todoItems")); + responseDocument.Results[5].Data.SingleValue.RefShould().NotBeNull().And.Subject.Type.Should().Be("todoItems"); responseDocument.Results[6].Data.Value.Should().BeNull(); - long newOwnerId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - long newAssigneeId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); - long newTagId = long.Parse(responseDocument.Results[2].Data.SingleValue!.Id.ShouldNotBeNull()); - long newTodoItemId = long.Parse(responseDocument.Results[3].Data.SingleValue!.Id.ShouldNotBeNull()); + long newOwnerId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + long newAssigneeId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + long newTagId = long.Parse(responseDocument.Results[2].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + long newTodoItemId = long.Parse(responseDocument.Results[3].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -203,14 +203,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.CreatedAt.Should().Be(DapperTestContext.FrozenTime); todoItemInDatabase.LastModifiedAt.Should().Be(DapperTestContext.FrozenTime); - todoItemInDatabase.Owner.ShouldNotBeNull(); + todoItemInDatabase.Owner.Should().NotBeNull(); todoItemInDatabase.Owner.Id.Should().Be(newOwnerId); todoItemInDatabase.Assignee.Should().BeNull(); - todoItemInDatabase.Tags.ShouldHaveCount(1); + todoItemInDatabase.Tags.Should().HaveCount(1); todoItemInDatabase.Tags.ElementAt(0).Id.Should().Be(newTagId); }); - store.SqlCommands.ShouldHaveCount(15); + store.SqlCommands.Should().HaveCount(15); store.SqlCommands[0].With(command => { @@ -220,7 +220,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", newOwner.FirstName); command.Parameters.Should().Contain("@p2", newOwner.LastName); command.Parameters.Should().Contain("@p3", null); @@ -234,7 +234,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newOwnerId); }); @@ -246,7 +246,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", newAssignee.FirstName); command.Parameters.Should().Contain("@p2", newAssignee.LastName); command.Parameters.Should().Contain("@p3", null); @@ -260,7 +260,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newAssigneeId); }); @@ -272,7 +272,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newTag.Name); command.Parameters.Should().Contain("@p2", null); }); @@ -285,7 +285,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTagId); }); @@ -297,7 +297,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(7); + command.Parameters.Should().HaveCount(7); command.Parameters.Should().Contain("@p1", newTodoItem.Description); command.Parameters.Should().Contain("@p2", newTodoItem.Priority); command.Parameters.Should().Contain("@p3", newTodoItem.DurationInHours); @@ -315,7 +315,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); @@ -328,7 +328,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); @@ -340,7 +340,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newAssigneeId); command.Parameters.Should().Contain("@p2", newTodoItemId); }); @@ -354,7 +354,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); @@ -366,7 +366,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", DapperTestContext.FrozenTime); command.Parameters.Should().Contain("@p2", newTodoItemId); }); @@ -379,7 +379,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newTodoItemId); command.Parameters.Should().Contain("@p2", newTagId); }); @@ -392,7 +392,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); @@ -403,7 +403,7 @@ DELETE FROM "People" WHERE "Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newAssigneeId); }); } @@ -469,13 +469,13 @@ public async Task Can_rollback_on_error() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'todoItems' with ID '{unknownTodoItemId}' in relationship 'assignedTodoItems' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -484,7 +484,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => peopleInDatabase.Should().BeEmpty(); }); - store.SqlCommands.ShouldHaveCount(5); + store.SqlCommands.Should().HaveCount(5); store.SqlCommands[0].With(command => { @@ -494,7 +494,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", newPerson.LastName); command.Parameters.Should().Contain("@p3", null); @@ -508,8 +508,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); - command.Parameters.ShouldContainKey("@p1").With(value => value.ShouldNotBeNull()); + command.Parameters.Should().HaveCount(1); + command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull(); }); store.SqlCommands[2].With(command => @@ -521,8 +521,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); - command.Parameters.ShouldContainKey("@p1").With(value => value.ShouldNotBeNull()); + command.Parameters.Should().HaveCount(1); + command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull(); }); store.SqlCommands[3].With(command => @@ -533,8 +533,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); - command.Parameters.ShouldContainKey("@p1").With(value => value.ShouldNotBeNull()); + command.Parameters.Should().HaveCount(2); + command.Parameters.Should().ContainKey("@p1").WhoseValue.Should().NotBeNull(); command.Parameters.Should().Contain("@p2", unknownTodoItemId); }); @@ -546,7 +546,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", unknownTodoItemId); }); } diff --git a/test/DapperTests/IntegrationTests/QueryStrings/FilterTests.cs b/test/DapperTests/IntegrationTests/QueryStrings/FilterTests.cs index 03ebd81bd9..f7da3533f9 100644 --- a/test/DapperTests/IntegrationTests/QueryStrings/FilterTests.cs +++ b/test/DapperTests/IntegrationTests/QueryStrings/FilterTests.cs @@ -50,13 +50,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("tags"); responseDocument.Data.ManyValue[0].Id.Should().Be(tags[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -67,7 +67,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", 0x00FF00); }); @@ -81,7 +81,7 @@ SELECT COUNT(*) ORDER BY t1."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", 0x00FF00); }); } @@ -115,13 +115,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("tags"); responseDocument.Data.ManyValue[0].Id.Should().Be(tags[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -132,7 +132,7 @@ SELECT COUNT(*) WHERE t2."Id" IN (@p1, @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", 0x00FF00); command.Parameters.Should().Contain("@p2", 0x11EE11); }); @@ -147,7 +147,7 @@ SELECT COUNT(*) ORDER BY t1."Id" """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", 0x00FF00); command.Parameters.Should().Contain("@p2", 0x11EE11); }); @@ -178,13 +178,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -196,7 +196,7 @@ SELECT COUNT(*) WHERE (t2."Id" = @p1) AND (t3."Id" IS NULL) """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); @@ -215,7 +215,7 @@ WHERE t3."Id" IS NULL ORDER BY t4."Priority", t4."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -245,13 +245,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -262,7 +262,7 @@ SELECT COUNT(*) WHERE (t2."Id" = @p1) AND (t1."DurationInHours" IS NULL) """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); @@ -280,7 +280,7 @@ WHERE t2."DurationInHours" IS NULL ORDER BY t3."Priority", t3."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -313,13 +313,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -329,7 +329,7 @@ SELECT COUNT(*) WHERE t1."Priority" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItems[1].Priority); }); @@ -342,7 +342,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItems[1].Priority); }); } @@ -375,13 +375,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(person.AssignedTodoItems.ElementAt(1).StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -392,7 +392,7 @@ SELECT COUNT(*) WHERE (t2."Id" = @p1) AND (t1."Description" = @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", person.Id); command.Parameters.Should().Contain("@p2", person.AssignedTodoItems.ElementAt(1).Description); }); @@ -411,7 +411,7 @@ LEFT JOIN ( ORDER BY t3."Priority", t3."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", person.Id); command.Parameters.Should().Contain("@p2", person.AssignedTodoItems.ElementAt(1).Description); }); @@ -445,13 +445,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -506,13 +506,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -523,7 +523,7 @@ SELECT COUNT(*) WHERE (t2."Id" = @p1) AND (t1."Priority" = @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", person.Id); command.Parameters.Should().Contain("@p2", TodoItemPriority.Medium); }); @@ -542,7 +542,7 @@ LEFT JOIN ( ORDER BY t3."Priority", t3."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", person.Id); command.Parameters.Should().Contain("@p2", TodoItemPriority.Medium); }); @@ -574,13 +574,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -590,7 +590,7 @@ SELECT COUNT(*) WHERE t1."Description" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", "X"); }); @@ -603,7 +603,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", "X"); }); } @@ -635,14 +635,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("people")); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == people[1].StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == people[2].StringId); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -652,7 +652,7 @@ SELECT COUNT(*) WHERE (NOT (t1."FirstName" = @p1)) OR (t1."FirstName" IS NULL) """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", "X"); }); @@ -665,7 +665,7 @@ SELECT COUNT(*) ORDER BY t1."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", "X"); }); } @@ -699,13 +699,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[0].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -716,7 +716,7 @@ SELECT COUNT(*) WHERE (NOT ((t2."FirstName" = @p1) AND (t2."LastName" = @p2))) OR (t2."FirstName" IS NULL) OR (t2."LastName" IS NULL) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", "X"); command.Parameters.Should().Contain("@p2", "Y"); }); @@ -731,7 +731,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", "X"); command.Parameters.Should().Contain("@p2", "Y"); }); @@ -768,13 +768,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -785,7 +785,7 @@ SELECT COUNT(*) WHERE (t1."Description" LIKE 'T%') AND (NOT (t1."Description" IN (@p1, @p2))) AND (t2."FirstName" = @p3) AND (t1."Description" LIKE '%o%') """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "Four"); command.Parameters.Should().Contain("@p2", "Three"); command.Parameters.Should().Contain("@p3", "Jack"); @@ -801,7 +801,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "Four"); command.Parameters.Should().Contain("@p2", "Three"); command.Parameters.Should().Contain("@p3", "Jack"); @@ -838,7 +838,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(5); + responseDocument.Data.ManyValue.Should().HaveCount(5); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == tags[0].StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == tags[1].StringId); @@ -848,7 +848,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().ContainTotal(5); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -903,14 +903,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == todoItems[0].StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == todoItems[2].StringId); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -920,7 +920,7 @@ SELECT COUNT(*) WHERE (t1."DurationInHours" > @p1) OR (t1."DurationInHours" <= @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", 250); command.Parameters.Should().Contain("@p2", 100); }); @@ -934,7 +934,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", 250); command.Parameters.Should().Contain("@p2", 100); }); @@ -968,13 +968,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -990,7 +990,7 @@ SELECT COUNT(*) ) > @p1) AND (NOT (t4."Id" IS NULL)) """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", 1); }); @@ -1009,7 +1009,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", 1); }); } @@ -1052,13 +1052,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -1078,7 +1078,7 @@ SELECT 1 ) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "Personal"); command.Parameters.Should().Contain("@p2", "Smith"); command.Parameters.Should().Contain("@p3", "Homework"); @@ -1103,7 +1103,7 @@ SELECT 1 ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "Personal"); command.Parameters.Should().Contain("@p2", "Smith"); command.Parameters.Should().Contain("@p3", "Homework"); @@ -1142,13 +1142,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("people"); responseDocument.Data.ManyValue[0].Id.Should().Be(people[2].StringId); responseDocument.Meta.Should().ContainTotal(1); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -1229,7 +1229,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == todoItems[2].StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Id == todoItems[3].StringId); @@ -1237,7 +1237,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().ContainTotal(3); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -1247,7 +1247,7 @@ SELECT COUNT(*) WHERE (t1."Description" = @p1) AND ((t1."Priority" = @p2) OR (t1."DurationInHours" = @p3)) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "1"); command.Parameters.Should().Contain("@p2", TodoItemPriority.High); command.Parameters.Should().Contain("@p3", 1); @@ -1262,7 +1262,7 @@ SELECT COUNT(*) ORDER BY t1."Priority", t1."LastModifiedAt" DESC """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", "1"); command.Parameters.Should().Contain("@p2", TodoItemPriority.High); command.Parameters.Should().Contain("@p3", 1); @@ -1292,7 +1292,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); diff --git a/test/DapperTests/IntegrationTests/QueryStrings/IncludeTests.cs b/test/DapperTests/IntegrationTests/QueryStrings/IncludeTests.cs index a1f06cd736..77805ee1b5 100644 --- a/test/DapperTests/IntegrationTests/QueryStrings/IncludeTests.cs +++ b/test/DapperTests/IntegrationTests/QueryStrings/IncludeTests.cs @@ -53,31 +53,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[0].StringId); responseDocument.Data.ManyValue[0].Relationships.With(relationships => { - relationships.ShouldContainKey("owner").With(value => + relationships.Should().ContainKey("owner").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("people"); value.Data.SingleValue.Id.Should().Be(todoItems[0].Owner.StringId); }); - relationships.ShouldContainKey("assignee").With(value => + relationships.Should().ContainKey("assignee").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.SingleValue.Should().BeNull(); }); - relationships.ShouldContainKey("tags").With(value => + relationships.Should().ContainKey("tags").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(2); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(2); value.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); value.Data.ManyValue[0].Id.Should().Be(todoItems[0].Tags.ElementAt(0).StringId); value.Data.ManyValue[1].Id.Should().Be(todoItems[0].Tags.ElementAt(1).StringId); @@ -88,63 +88,63 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Data.ManyValue[1].Relationships.With(relationships => { - relationships.ShouldContainKey("owner").With(value => + relationships.Should().ContainKey("owner").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("people"); value.Data.SingleValue.Id.Should().Be(todoItems[1].Owner.StringId); }); - relationships.ShouldContainKey("assignee").With(value => + relationships.Should().ContainKey("assignee").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("people"); value.Data.SingleValue.Id.Should().Be(todoItems[1].Assignee!.StringId); }); - relationships.ShouldContainKey("tags").With(value => + relationships.Should().ContainKey("tags").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(2); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(2); value.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); value.Data.ManyValue[0].Id.Should().Be(todoItems[1].Tags.ElementAt(0).StringId); value.Data.ManyValue[1].Id.Should().Be(todoItems[1].Tags.ElementAt(1).StringId); }); }); - responseDocument.Included.ShouldHaveCount(6); + responseDocument.Included.Should().HaveCount(6); responseDocument.Included[0].Type.Should().Be("people"); responseDocument.Included[0].Id.Should().Be(owner.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(owner.FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(owner.LastName)); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(owner.FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(owner.LastName); responseDocument.Included[1].Type.Should().Be("tags"); responseDocument.Included[1].Id.Should().Be(todoItems[0].Tags.ElementAt(0).StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItems[0].Tags.ElementAt(0).Name)); + responseDocument.Included[1].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItems[0].Tags.ElementAt(0).Name); responseDocument.Included[2].Type.Should().Be("tags"); responseDocument.Included[2].Id.Should().Be(todoItems[0].Tags.ElementAt(1).StringId); - responseDocument.Included[2].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItems[0].Tags.ElementAt(1).Name)); + responseDocument.Included[2].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItems[0].Tags.ElementAt(1).Name); responseDocument.Included[3].Type.Should().Be("people"); responseDocument.Included[3].Id.Should().Be(todoItems[1].Assignee!.StringId); - responseDocument.Included[3].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(todoItems[1].Assignee!.FirstName)); - responseDocument.Included[3].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(todoItems[1].Assignee!.LastName)); + responseDocument.Included[3].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(todoItems[1].Assignee!.FirstName); + responseDocument.Included[3].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItems[1].Assignee!.LastName); responseDocument.Included[4].Type.Should().Be("tags"); responseDocument.Included[4].Id.Should().Be(todoItems[1].Tags.ElementAt(0).StringId); - responseDocument.Included[4].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItems[1].Tags.ElementAt(0).Name)); + responseDocument.Included[4].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItems[1].Tags.ElementAt(0).Name); responseDocument.Included[5].Type.Should().Be("tags"); responseDocument.Included[5].Id.Should().Be(todoItems[1].Tags.ElementAt(1).StringId); - responseDocument.Included[5].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItems[1].Tags.ElementAt(1).Name)); + responseDocument.Included[5].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItems[1].Tags.ElementAt(1).Name); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -199,20 +199,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(25); + responseDocument.Data.ManyValue.Should().HaveCount(25); responseDocument.Data.ManyValue.ForEach(resource => { resource.Type.Should().Be("todoItems"); - resource.Attributes.ShouldOnlyContainKeys("description", "priority", "durationInHours", "createdAt", "modifiedAt"); - resource.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + resource.Attributes.Should().OnlyContainKeys("description", "priority", "durationInHours", "createdAt", "modifiedAt"); + resource.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); }); - responseDocument.Included.ShouldHaveCount(25 * 15 * 2); + responseDocument.Included.Should().HaveCount(25 * 15 * 2); responseDocument.Meta.Should().ContainTotal(25); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { diff --git a/test/DapperTests/IntegrationTests/QueryStrings/PaginationTests.cs b/test/DapperTests/IntegrationTests/QueryStrings/PaginationTests.cs index e87469cfbf..854fb176db 100644 --- a/test/DapperTests/IntegrationTests/QueryStrings/PaginationTests.cs +++ b/test/DapperTests/IntegrationTests/QueryStrings/PaginationTests.cs @@ -41,7 +41,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.InternalServerError); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.InternalServerError); diff --git a/test/DapperTests/IntegrationTests/QueryStrings/SortTests.cs b/test/DapperTests/IntegrationTests/QueryStrings/SortTests.cs index 6a66d5e7e3..488dda2cc3 100644 --- a/test/DapperTests/IntegrationTests/QueryStrings/SortTests.cs +++ b/test/DapperTests/IntegrationTests/QueryStrings/SortTests.cs @@ -50,13 +50,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[2].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(todoItems[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(todoItems[1].StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -113,18 +113,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(2).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(person.OwnedTodoItems.ElementAt(0).StringId); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); responseDocument.Included[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).Tags.ElementAt(1).StringId); responseDocument.Included[1].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).Tags.ElementAt(0).StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -135,7 +135,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); @@ -150,7 +150,7 @@ SELECT COUNT(*) ORDER BY t2."DurationInHours" DESC, t3."Name" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -184,13 +184,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[2].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(todoItems[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(todoItems[1].StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -247,13 +247,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(2).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(person.OwnedTodoItems.ElementAt(0).StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -264,7 +264,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); @@ -282,7 +282,7 @@ SELECT COUNT(*) ) DESC, t2."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -316,13 +316,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(2).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(person.OwnedTodoItems.ElementAt(0).StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -333,7 +333,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); @@ -352,7 +352,7 @@ SELECT COUNT(*) ) DESC, t2."Id", t4."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -386,18 +386,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("people"); responseDocument.Data.ManyValue[0].Id.Should().Be(person.StringId); - responseDocument.Included.ShouldHaveCount(4); + responseDocument.Included.Should().HaveCount(4); responseDocument.Included.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Included[0].Id.Should().Be(person.OwnedTodoItems.ElementAt(2).StringId); responseDocument.Included[1].Id.Should().Be(person.OwnedTodoItems.ElementAt(0).StringId); responseDocument.Included[2].Id.Should().Be(person.OwnedTodoItems.ElementAt(1).StringId); responseDocument.Included[3].Id.Should().Be(person.OwnedTodoItems.ElementAt(3).StringId); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { diff --git a/test/DapperTests/IntegrationTests/QueryStrings/SparseFieldSets.cs b/test/DapperTests/IntegrationTests/QueryStrings/SparseFieldSets.cs index af09f014a2..b2e0c68f8c 100644 --- a/test/DapperTests/IntegrationTests/QueryStrings/SparseFieldSets.cs +++ b/test/DapperTests/IntegrationTests/QueryStrings/SparseFieldSets.cs @@ -47,44 +47,44 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("todoItems"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(2); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItem.Description)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(todoItem.DurationInHours)); - responseDocument.Data.ManyValue[0].Relationships.ShouldHaveCount(2); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(2); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(todoItem.DurationInHours); + responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(2); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("owner").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("owner").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("people"); value.Data.SingleValue.Id.Should().Be(todoItem.Owner.StringId); }); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("assignee").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("assignee").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("people"); value.Data.SingleValue.Id.Should().Be(todoItem.Assignee.StringId); }); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().AllSatisfy(resource => resource.Type.Should().Be("people")); responseDocument.Included[0].Id.Should().Be(todoItem.Owner.StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(todoItem.Owner.LastName)); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItem.Owner.LastName); responseDocument.Included[0].Relationships.Should().BeNull(); responseDocument.Included[1].Id.Should().Be(todoItem.Assignee.StringId); - responseDocument.Included[1].Attributes.ShouldHaveCount(1); - responseDocument.Included[1].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(todoItem.Assignee.LastName)); + responseDocument.Included[1].Attributes.Should().HaveCount(1); + responseDocument.Included[1].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItem.Assignee.LastName); responseDocument.Included[1].Relationships.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -134,14 +134,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); responseDocument.Data.SingleValue.Id.Should().Be(todoItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItem.Description)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -151,7 +151,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -181,19 +181,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("tags"); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.Tags.ElementAt(0).StringId); responseDocument.Data.ManyValue[0].Attributes.Should().BeNull(); - responseDocument.Data.ManyValue[0].Relationships.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("color").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("color").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -204,7 +204,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); @@ -218,7 +218,7 @@ SELECT COUNT(*) ORDER BY t2."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -246,13 +246,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be(person.StringId); responseDocument.Data.SingleValue.Attributes.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -262,7 +262,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -290,13 +290,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be(person.StringId); responseDocument.Data.SingleValue.Attributes.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -306,7 +306,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -334,14 +334,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be(person.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(person.DisplayName)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(person.DisplayName); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -351,7 +351,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", person.Id); }); } @@ -381,17 +381,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); responseDocument.Data.SingleValue.Id.Should().Be(todoItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItem.Description)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -403,7 +403,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ORDER BY t2."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/AddToToManyRelationshipTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/AddToToManyRelationshipTests.cs index 2bf6277f10..6f5a87ea33 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/AddToToManyRelationshipTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/AddToToManyRelationshipTests.cs @@ -73,10 +73,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.OwnedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.OwnedTodoItems.ShouldHaveCount(3); + personInDatabase.OwnedTodoItems.Should().HaveCount(3); }); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" IN (@p2, @p3) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingTodoItems.ElementAt(1).Id); diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/FetchRelationshipTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/FetchRelationshipTests.cs index 949494e5f0..d4703dc99a 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/FetchRelationshipTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/FetchRelationshipTests.cs @@ -46,13 +46,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be(todoItem.Owner.StringId); responseDocument.Meta.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -63,7 +63,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -97,7 +97,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -108,7 +108,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -139,14 +139,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.Tags.ElementAt(0).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(todoItem.Tags.ElementAt(1).StringId); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -157,7 +157,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); @@ -171,7 +171,7 @@ SELECT COUNT(*) ORDER BY t2."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -189,7 +189,7 @@ public async Task Cannot_get_relationship_for_unknown_primary_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/RemoveFromToManyRelationshipTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/RemoveFromToManyRelationshipTests.cs index 82dace581f..ac6be3134e 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/RemoveFromToManyRelationshipTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/RemoveFromToManyRelationshipTests.cs @@ -70,7 +70,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.AssignedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.AssignedTodoItems.ShouldHaveCount(1); + personInDatabase.AssignedTodoItems.Should().HaveCount(1); personInDatabase.AssignedTodoItems.ElementAt(0).Id.Should().Be(existingPerson.AssignedTodoItems.ElementAt(1).Id); List todoItemInDatabases = await dbContext.TodoItems.Where(todoItem => todoItem.Assignee == null).ToListAsync(); @@ -78,7 +78,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabases.Should().HaveCount(2); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -93,7 +93,7 @@ LEFT JOIN ( WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingPerson.AssignedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingPerson.AssignedTodoItems.ElementAt(2).Id); @@ -107,7 +107,7 @@ SELECT t1."Id" WHERE t1."Id" IN (@p1, @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.AssignedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p2", existingPerson.AssignedTodoItems.ElementAt(2).Id); }); @@ -120,7 +120,7 @@ SELECT t1."Id" WHERE "Id" IN (@p2, @p3) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingPerson.AssignedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingPerson.AssignedTodoItems.ElementAt(2).Id); @@ -175,7 +175,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.OwnedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.OwnedTodoItems.ShouldHaveCount(1); + personInDatabase.OwnedTodoItems.Should().HaveCount(1); personInDatabase.OwnedTodoItems.ElementAt(0).Id.Should().Be(existingPerson.OwnedTodoItems.ElementAt(1).Id); List todoItemInDatabases = await dbContext.TodoItems.ToListAsync(); @@ -183,7 +183,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabases.Should().HaveCount(1); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -198,7 +198,7 @@ LEFT JOIN ( WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingPerson.OwnedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingPerson.OwnedTodoItems.ElementAt(2).Id); @@ -212,7 +212,7 @@ SELECT t1."Id" WHERE t1."Id" IN (@p1, @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.OwnedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p2", existingPerson.OwnedTodoItems.ElementAt(2).Id); }); @@ -224,7 +224,7 @@ DELETE FROM "TodoItems" WHERE "Id" IN (@p1, @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.OwnedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p2", existingPerson.OwnedTodoItems.ElementAt(2).Id); }); diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/ReplaceToManyRelationshipTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/ReplaceToManyRelationshipTests.cs index d2a4d0865a..a46a34678b 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/ReplaceToManyRelationshipTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/ReplaceToManyRelationshipTests.cs @@ -59,7 +59,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => personInDatabase.AssignedTodoItems.Should().BeEmpty(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -70,7 +70,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -82,7 +82,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" IN (@p2, @p3) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingPerson.AssignedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingPerson.AssignedTodoItems.ElementAt(1).Id); @@ -127,7 +127,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => personInDatabase.OwnedTodoItems.Should().BeEmpty(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -138,7 +138,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -149,7 +149,7 @@ DELETE FROM "TodoItems" WHERE "Id" IN (@p1, @p2) """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.OwnedTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p2", existingPerson.OwnedTodoItems.ElementAt(1).Id); }); @@ -204,12 +204,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.AssignedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.AssignedTodoItems.ShouldHaveCount(2); + personInDatabase.AssignedTodoItems.Should().HaveCount(2); personInDatabase.AssignedTodoItems.ElementAt(0).Id.Should().Be(existingTodoItems.ElementAt(0).Id); personInDatabase.AssignedTodoItems.ElementAt(1).Id.Should().Be(existingTodoItems.ElementAt(1).Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -220,7 +220,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -232,7 +232,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" IN (@p2, @p3) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingTodoItems.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingTodoItems.ElementAt(1).Id); @@ -284,11 +284,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.AssignedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.AssignedTodoItems.ShouldHaveCount(1); + personInDatabase.AssignedTodoItems.Should().HaveCount(1); personInDatabase.AssignedTodoItems.ElementAt(0).Id.Should().Be(existingTodoItem.Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -299,7 +299,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -311,7 +311,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingPerson.AssignedTodoItems.ElementAt(0).Id); }); @@ -324,7 +324,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingTodoItem.Id); }); @@ -375,11 +375,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.OwnedTodoItems).FirstWithIdAsync(existingPerson.Id); - personInDatabase.OwnedTodoItems.ShouldHaveCount(1); + personInDatabase.OwnedTodoItems.Should().HaveCount(1); personInDatabase.OwnedTodoItems.ElementAt(0).Id.Should().Be(existingTodoItem.Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -390,7 +390,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -401,7 +401,7 @@ DELETE FROM "TodoItems" WHERE "Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.OwnedTodoItems.ElementAt(0).Id); }); @@ -413,7 +413,7 @@ DELETE FROM "TodoItems" WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingTodoItem.Id); }); diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/UpdateToOneRelationshipTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/UpdateToOneRelationshipTests.cs index 5f3b2ad0fb..bab60bf29b 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Relationships/UpdateToOneRelationshipTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Relationships/UpdateToOneRelationshipTests.cs @@ -65,7 +65,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => loginAccountInDatabase.Person.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -76,7 +76,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -88,7 +88,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingPerson.Id); }); @@ -137,7 +137,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => personInDatabase.Account.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -148,7 +148,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); }); @@ -160,7 +160,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingLoginAccount.Person.Id); }); @@ -196,7 +196,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Should().BeEmpty(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); }); } @@ -240,7 +240,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -248,7 +248,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'recovery' on resource type 'loginAccounts' cannot be cleared because it is a required relationship."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -259,7 +259,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); }); } @@ -292,7 +292,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'account' on resource type 'accountRecoveries' cannot be cleared because it is a required relationship."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -311,7 +311,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingAccountRecovery.Id); }); } @@ -354,7 +354,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.Assignee.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -365,7 +365,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); @@ -377,7 +377,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingTodoItem.Id); }); @@ -411,7 +411,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -419,7 +419,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'owner' on resource type 'todoItems' cannot be cleared because it is a required relationship."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -430,7 +430,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); } @@ -475,11 +475,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson.Id); - personInDatabase.Account.ShouldNotBeNull(); + personInDatabase.Account.Should().NotBeNull(); personInDatabase.Account.Id.Should().Be(existingLoginAccount.Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -490,7 +490,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson.Id); }); @@ -502,7 +502,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "AccountId" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingLoginAccount.Id); }); @@ -515,7 +515,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); command.Parameters.Should().Contain("@p2", existingPerson.Id); }); @@ -562,11 +562,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => LoginAccount loginAccountInDatabase = await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Person).FirstWithIdAsync(existingLoginAccount.Id); - loginAccountInDatabase.Person.ShouldNotBeNull(); + loginAccountInDatabase.Person.Should().NotBeNull(); loginAccountInDatabase.Person.Id.Should().Be(existingPerson.Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -577,7 +577,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); }); @@ -589,7 +589,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingLoginAccount.Id); command.Parameters.Should().Contain("@p2", existingPerson.Id); }); @@ -635,11 +635,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { TodoItem todoItemInDatabase = await dbContext.TodoItems.Include(todoItem => todoItem.Assignee).FirstWithIdAsync(existingTodoItem.Id); - todoItemInDatabase.Assignee.ShouldNotBeNull(); + todoItemInDatabase.Assignee.Should().NotBeNull(); todoItemInDatabase.Assignee.Id.Should().Be(existingPerson.Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -650,7 +650,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); @@ -662,7 +662,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson.Id); command.Parameters.Should().Contain("@p2", existingTodoItem.Id); }); @@ -711,7 +711,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Person personInDatabase1 = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson1.Id); - personInDatabase1.Account.ShouldNotBeNull(); + personInDatabase1.Account.Should().NotBeNull(); personInDatabase1.Account.Id.Should().Be(existingPerson2.Account.Id); Person personInDatabase2 = await dbContext.People.Include(person => person.Account).FirstWithIdAsync(existingPerson2.Id); @@ -719,7 +719,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => personInDatabase2.Account.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -730,7 +730,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingPerson1.Id); }); @@ -742,7 +742,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "AccountId" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingPerson2.Account.Id); }); @@ -755,7 +755,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingPerson2.Account.Id); command.Parameters.Should().Contain("@p2", existingPerson1.Id); }); @@ -805,7 +805,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => LoginAccount loginAccountInDatabase1 = await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Person).FirstWithIdAsync(existingLoginAccount1.Id); - loginAccountInDatabase1.Person.ShouldNotBeNull(); + loginAccountInDatabase1.Person.Should().NotBeNull(); loginAccountInDatabase1.Person.Id.Should().Be(existingLoginAccount2.Person.Id); LoginAccount loginAccountInDatabase2 = @@ -814,7 +814,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => loginAccountInDatabase2.Person.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -825,7 +825,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount1.Id); }); @@ -837,7 +837,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingLoginAccount1.Person.Id); }); @@ -850,7 +850,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingLoginAccount1.Id); command.Parameters.Should().Contain("@p2", existingLoginAccount2.Person.Id); }); @@ -898,7 +898,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => LoginAccount loginAccountInDatabase1 = await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Recovery).FirstWithIdAsync(existingLoginAccount1.Id); - loginAccountInDatabase1.Recovery.ShouldNotBeNull(); + loginAccountInDatabase1.Recovery.Should().NotBeNull(); loginAccountInDatabase1.Recovery.Id.Should().Be(existingLoginAccount2.Recovery.Id); LoginAccount? loginAccountInDatabase2 = await dbContext.LoginAccounts.Include(loginAccount => loginAccount.Recovery) @@ -907,7 +907,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => loginAccountInDatabase2.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -918,7 +918,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount1.Id); }); @@ -929,7 +929,7 @@ DELETE FROM "LoginAccounts" WHERE "RecoveryId" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingLoginAccount2.Recovery.Id); }); @@ -941,7 +941,7 @@ DELETE FROM "LoginAccounts" WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingLoginAccount2.Recovery.Id); command.Parameters.Should().Contain("@p2", existingLoginAccount1.Id); }); @@ -989,7 +989,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => AccountRecovery accountRecoveryInDatabase1 = await dbContext.AccountRecoveries.Include(recovery => recovery.Account).FirstWithIdAsync(existingAccountRecovery1.Id); - accountRecoveryInDatabase1.Account.ShouldNotBeNull(); + accountRecoveryInDatabase1.Account.Should().NotBeNull(); accountRecoveryInDatabase1.Account.Id.Should().Be(existingAccountRecovery2.Account.Id); AccountRecovery accountRecoveryInDatabase2 = @@ -998,7 +998,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => accountRecoveryInDatabase2.Account.Should().BeNull(); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -1009,7 +1009,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingAccountRecovery1.Id); }); @@ -1020,7 +1020,7 @@ DELETE FROM "LoginAccounts" WHERE "Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingAccountRecovery1.Account.Id); }); @@ -1032,7 +1032,7 @@ DELETE FROM "LoginAccounts" WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingAccountRecovery1.Id); command.Parameters.Should().Contain("@p2", existingAccountRecovery2.Account.Id); }); @@ -1081,11 +1081,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { TodoItem todoItemInDatabase1 = await dbContext.TodoItems.Include(todoItem => todoItem.Assignee).FirstWithIdAsync(existingTodoItem1.Id); - todoItemInDatabase1.Assignee.ShouldNotBeNull(); + todoItemInDatabase1.Assignee.Should().NotBeNull(); todoItemInDatabase1.Assignee.Id.Should().Be(existingTodoItem2.Assignee.Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -1096,7 +1096,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem1.Id); }); @@ -1108,7 +1108,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingTodoItem2.Assignee.Id); command.Parameters.Should().Contain("@p2", existingTodoItem1.Id); }); @@ -1155,11 +1155,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { TodoItem todoItemInDatabase1 = await dbContext.TodoItems.Include(todoItem => todoItem.Owner).FirstWithIdAsync(existingTodoItem1.Id); - todoItemInDatabase1.Owner.ShouldNotBeNull(); + todoItemInDatabase1.Owner.Should().NotBeNull(); todoItemInDatabase1.Owner.Id.Should().Be(existingTodoItem2.Owner.Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -1170,7 +1170,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem1.Id); }); @@ -1182,7 +1182,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingTodoItem2.Owner.Id); command.Parameters.Should().Contain("@p2", existingTodoItem1.Id); }); diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Resources/CreateResourceTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Resources/CreateResourceTests.cs index 1f3a540315..ce74e99839 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Resources/CreateResourceTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Resources/CreateResourceTests.cs @@ -92,17 +92,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newTodoItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(newTodoItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(newTodoItem.DurationInHours)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(DapperTestContext.FrozenTime)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newTodoItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(newTodoItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(newTodoItem.DurationInHours); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(DapperTestContext.FrozenTime); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().BeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); - long newTodoItemId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newTodoItemId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); httpResponse.Headers.Location.Should().Be($"/todoItems/{newTodoItemId}"); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -125,15 +125,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.CreatedAt.Should().Be(DapperTestContext.FrozenTime); todoItemInDatabase.LastModifiedAt.Should().BeNull(); - todoItemInDatabase.Owner.ShouldNotBeNull(); + todoItemInDatabase.Owner.Should().NotBeNull(); todoItemInDatabase.Owner.Id.Should().Be(existingPerson.Id); - todoItemInDatabase.Assignee.ShouldNotBeNull(); + todoItemInDatabase.Assignee.Should().NotBeNull(); todoItemInDatabase.Assignee.Id.Should().Be(existingPerson.Id); - todoItemInDatabase.Tags.ShouldHaveCount(1); + todoItemInDatabase.Tags.Should().HaveCount(1); todoItemInDatabase.Tags.ElementAt(0).Id.Should().Be(existingTag.Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -143,7 +143,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(7); + command.Parameters.Should().HaveCount(7); command.Parameters.Should().Contain("@p1", newTodoItem.Description); command.Parameters.Should().Contain("@p2", newTodoItem.Priority); command.Parameters.Should().Contain("@p3", newTodoItem.DurationInHours); @@ -161,7 +161,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newTodoItemId); command.Parameters.Should().Contain("@p2", existingTag.Id); }); @@ -174,7 +174,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); } @@ -228,16 +228,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newTodoItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(newTodoItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("durationInHours").With(value => value.Should().BeNull()); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(DapperTestContext.FrozenTime)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().BeNull()); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newTodoItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(newTodoItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().BeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(DapperTestContext.FrozenTime); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().BeNull(); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); - long newTodoItemId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newTodoItemId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -259,13 +259,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.CreatedAt.Should().Be(DapperTestContext.FrozenTime); todoItemInDatabase.LastModifiedAt.Should().BeNull(); - todoItemInDatabase.Owner.ShouldNotBeNull(); + todoItemInDatabase.Owner.Should().NotBeNull(); todoItemInDatabase.Owner.Id.Should().Be(existingPerson.Id); todoItemInDatabase.Assignee.Should().BeNull(); todoItemInDatabase.Tags.Should().BeEmpty(); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -275,7 +275,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(7); + command.Parameters.Should().HaveCount(7); command.Parameters.Should().Contain("@p1", newTodoItem.Description); command.Parameters.Should().Contain("@p2", newTodoItem.Priority); command.Parameters.Should().Contain("@p3", null); @@ -293,7 +293,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newTodoItemId); }); } @@ -324,27 +324,27 @@ public async Task Cannot_create_resource_without_required_fields() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(3); + responseDocument.Errors.Should().HaveCount(3); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Owner field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/relationships/owner/data"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The Priority field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/attributes/priority"); ErrorObject error3 = responseDocument.Errors[2]; error3.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error3.Title.Should().Be("Input validation failed."); error3.Detail.Should().Be("The Description field is required."); - error3.Source.ShouldNotBeNull(); + error3.Source.Should().NotBeNull(); error3.Source.Pointer.Should().Be("/data/attributes/description"); store.SqlCommands.Should().BeEmpty(); @@ -407,13 +407,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("loginAccounts"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("userName").With(value => value.Should().Be(newUserName)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(newUserName); responseDocument.Data.SingleValue.Attributes.Should().NotContainKey("lastUsedAt"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("recovery", "person"); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("recovery", "person"); - long newLoginAccountId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newLoginAccountId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -431,13 +431,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => loginAccountInDatabase.UserName.Should().Be(newUserName); loginAccountInDatabase.LastUsedAt.Should().BeNull(); - loginAccountInDatabase.Recovery.ShouldNotBeNull(); + loginAccountInDatabase.Recovery.Should().NotBeNull(); loginAccountInDatabase.Recovery.Id.Should().Be(existingAccountRecovery.Id); - loginAccountInDatabase.Person.ShouldNotBeNull(); + loginAccountInDatabase.Person.Should().NotBeNull(); loginAccountInDatabase.Person.Id.Should().Be(existingPerson.Id); }); - store.SqlCommands.ShouldHaveCount(4); + store.SqlCommands.Should().HaveCount(4); store.SqlCommands[0].With(command => { @@ -446,7 +446,7 @@ DELETE FROM "LoginAccounts" WHERE "RecoveryId" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingAccountRecovery.Id); }); @@ -458,7 +458,7 @@ DELETE FROM "LoginAccounts" RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", newUserName); command.Parameters.Should().Contain("@p2", null); command.Parameters.Should().Contain("@p3", existingAccountRecovery.Id); @@ -472,7 +472,7 @@ DELETE FROM "LoginAccounts" WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newLoginAccountId); command.Parameters.Should().Contain("@p2", existingPerson.Id); }); @@ -485,7 +485,7 @@ DELETE FROM "LoginAccounts" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newLoginAccountId); }); } @@ -520,14 +520,14 @@ public async Task Can_create_resource_with_calculated_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(newPerson.FirstName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(newPerson.LastName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(newPerson.DisplayName)); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("account", "ownedTodoItems", "assignedTodoItems"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(newPerson.FirstName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(newPerson.LastName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(newPerson.DisplayName); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("account", "ownedTodoItems", "assignedTodoItems"); - long newPersonId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newPersonId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -538,7 +538,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => personInDatabase.DisplayName.Should().Be(newPerson.DisplayName); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -548,7 +548,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RETURNING "Id" """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", newPerson.FirstName); command.Parameters.Should().Contain("@p2", newPerson.LastName); command.Parameters.Should().Contain("@p3", null); @@ -562,7 +562,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newPersonId); }); } @@ -623,11 +623,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => colorInDatabase.Green.Should().Be(newColor.Green); colorInDatabase.Blue.Should().Be(newColor.Blue); - colorInDatabase.Tag.ShouldNotBeNull(); + colorInDatabase.Tag.Should().NotBeNull(); colorInDatabase.Tag.Id.Should().Be(existingTag.Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -636,7 +636,7 @@ DELETE FROM "RgbColors" WHERE "TagId" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTag.Id); }); @@ -648,7 +648,7 @@ DELETE FROM "RgbColors" RETURNING "Id" """, true)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", newColor.Id); command.Parameters.Should().Contain("@p2", existingTag.Id); }); @@ -661,7 +661,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", newColor.Id); }); } @@ -713,7 +713,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); @@ -721,7 +721,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Another resource of type 'rgbColors' with ID '{existingColor.StringId}' already exists."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -730,7 +730,7 @@ DELETE FROM "RgbColors" WHERE "TagId" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTag.Id); }); @@ -742,7 +742,7 @@ DELETE FROM "RgbColors" RETURNING "Id" """, true)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingColor.Id); command.Parameters.Should().Contain("@p2", existingTag.Id); }); @@ -755,7 +755,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingColor.Id); }); } diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Resources/DeleteResourceTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Resources/DeleteResourceTests.cs index 842f736ee9..566c546c73 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Resources/DeleteResourceTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Resources/DeleteResourceTests.cs @@ -59,10 +59,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => List tags = await dbContext.Tags.Where(tag => tag.TodoItem == null).ToListAsync(); - tags.ShouldHaveCount(1); + tags.Should().HaveCount(1); }); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -71,7 +71,7 @@ DELETE FROM "TodoItems" WHERE "Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); } @@ -93,7 +93,7 @@ public async Task Cannot_delete_unknown_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -101,7 +101,7 @@ public async Task Cannot_delete_unknown_resource() error.Detail.Should().Be($"Resource of type 'todoItems' with ID '{unknownTodoItemId}' does not exist."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -110,7 +110,7 @@ DELETE FROM "TodoItems" WHERE "Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", unknownTodoItemId); }); @@ -122,7 +122,7 @@ SELECT t1."Id" WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", unknownTodoItemId); }); } diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Resources/FetchResourceTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Resources/FetchResourceTests.cs index 20d08e1b9f..bd7139e5c4 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Resources/FetchResourceTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Resources/FetchResourceTests.cs @@ -49,28 +49,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("todoItems")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItems[1].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItems[1].Description)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("priority").With(value => value.Should().Be(todoItems[1].Priority)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(todoItems[1].DurationInHours)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(todoItems[1].CreatedAt)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().Be(todoItems[1].LastModifiedAt)); - responseDocument.Data.ManyValue[0].Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItems[1].Description); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(todoItems[1].Priority); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(todoItems[1].DurationInHours); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(todoItems[1].CreatedAt); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().Be(todoItems[1].LastModifiedAt); + responseDocument.Data.ManyValue[0].Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); responseDocument.Data.ManyValue[1].Id.Should().Be(todoItems[0].StringId); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItems[0].Description)); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("priority").With(value => value.Should().Be(todoItems[0].Priority)); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(todoItems[0].DurationInHours)); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(todoItems[0].CreatedAt)); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().Be(todoItems[0].LastModifiedAt)); - responseDocument.Data.ManyValue[1].Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItems[0].Description); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(todoItems[0].Priority); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(todoItems[0].DurationInHours); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(todoItems[0].CreatedAt); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().Be(todoItems[0].LastModifiedAt); + responseDocument.Data.ManyValue[1].Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -118,19 +118,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); responseDocument.Data.SingleValue.Id.Should().Be(todoItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(todoItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(todoItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(todoItem.DurationInHours)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(todoItem.CreatedAt)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().Be(todoItem.LastModifiedAt)); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(todoItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(todoItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(todoItem.DurationInHours); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(todoItem.CreatedAt); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().Be(todoItem.LastModifiedAt); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); responseDocument.Meta.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -140,7 +140,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -162,7 +162,7 @@ public async Task Cannot_get_unknown_primary_resource_by_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -170,7 +170,7 @@ public async Task Cannot_get_unknown_primary_resource_by_ID() error.Detail.Should().Be($"Resource of type 'todoItems' with ID '{unknownTodoItemId}' does not exist."); error.Source.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -180,7 +180,7 @@ public async Task Cannot_get_unknown_primary_resource_by_ID() WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", unknownTodoItemId); }); } @@ -211,20 +211,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Type.Should().Be("tags")); responseDocument.Data.ManyValue[0].Id.Should().Be(todoItem.Tags.ElementAt(0).StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItem.Tags.ElementAt(0).Name)); - responseDocument.Data.ManyValue[0].Relationships.ShouldOnlyContainKeys("todoItem", "color"); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItem.Tags.ElementAt(0).Name); + responseDocument.Data.ManyValue[0].Relationships.Should().OnlyContainKeys("todoItem", "color"); responseDocument.Data.ManyValue[1].Id.Should().Be(todoItem.Tags.ElementAt(1).StringId); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("name").With(value => value.Should().Be(todoItem.Tags.ElementAt(1).Name)); - responseDocument.Data.ManyValue[1].Relationships.ShouldOnlyContainKeys("todoItem", "color"); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(todoItem.Tags.ElementAt(1).Name); + responseDocument.Data.ManyValue[1].Relationships.Should().OnlyContainKeys("todoItem", "color"); responseDocument.Meta.Should().ContainTotal(2); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -235,7 +235,7 @@ SELECT COUNT(*) WHERE t2."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); @@ -249,7 +249,7 @@ SELECT COUNT(*) ORDER BY t2."Id" """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -278,17 +278,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be(todoItem.Owner.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(todoItem.Owner.FirstName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(todoItem.Owner.LastName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(todoItem.Owner.DisplayName)); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("account", "ownedTodoItems", "assignedTodoItems"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(todoItem.Owner.FirstName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(todoItem.Owner.LastName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(todoItem.Owner.DisplayName); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("account", "ownedTodoItems", "assignedTodoItems"); responseDocument.Meta.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -299,7 +299,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } @@ -332,7 +332,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().BeNull(); - store.SqlCommands.ShouldHaveCount(1); + store.SqlCommands.Should().HaveCount(1); store.SqlCommands[0].With(command => { @@ -343,7 +343,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", todoItem.Id); }); } diff --git a/test/DapperTests/IntegrationTests/ReadWrite/Resources/UpdateResourceTests.cs b/test/DapperTests/IntegrationTests/ReadWrite/Resources/UpdateResourceTests.cs index b248db2e02..dc8bccf5ee 100644 --- a/test/DapperTests/IntegrationTests/ReadWrite/Resources/UpdateResourceTests.cs +++ b/test/DapperTests/IntegrationTests/ReadWrite/Resources/UpdateResourceTests.cs @@ -69,11 +69,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => Tag tagInDatabase = await dbContext.Tags.Include(tag => tag.Color).FirstWithIdAsync(existingTag.Id); tagInDatabase.Name.Should().Be(existingTag.Name); - tagInDatabase.Color.ShouldNotBeNull(); + tagInDatabase.Color.Should().NotBeNull(); tagInDatabase.Color.Id.Should().Be(existingTag.Color.Id); }); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -83,7 +83,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTag.Id); }); @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTag.Id); }); } @@ -143,15 +143,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingTodoItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newDescription)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingTodoItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(newDurationInHours)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(existingTodoItem.CreatedAt)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().Be(DapperTestContext.FrozenTime)); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newDescription); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingTodoItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(newDurationInHours); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(existingTodoItem.CreatedAt); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().Be(DapperTestContext.FrozenTime); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -173,15 +173,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.CreatedAt.Should().Be(existingTodoItem.CreatedAt); todoItemInDatabase.LastModifiedAt.Should().Be(DapperTestContext.FrozenTime); - todoItemInDatabase.Owner.ShouldNotBeNull(); + todoItemInDatabase.Owner.Should().NotBeNull(); todoItemInDatabase.Owner.Id.Should().Be(existingTodoItem.Owner.Id); - todoItemInDatabase.Assignee.ShouldNotBeNull(); + todoItemInDatabase.Assignee.Should().NotBeNull(); todoItemInDatabase.Assignee.Id.Should().Be(existingTodoItem.Assignee.Id); - todoItemInDatabase.Tags.ShouldHaveCount(1); + todoItemInDatabase.Tags.Should().HaveCount(1); todoItemInDatabase.Tags.ElementAt(0).Id.Should().Be(existingTodoItem.Tags.ElementAt(0).Id); }); - store.SqlCommands.ShouldHaveCount(3); + store.SqlCommands.Should().HaveCount(3); store.SqlCommands[0].With(command => { @@ -191,7 +191,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); @@ -203,7 +203,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p4 """)); - command.Parameters.ShouldHaveCount(4); + command.Parameters.Should().HaveCount(4); command.Parameters.Should().Contain("@p1", newDescription); command.Parameters.Should().Contain("@p2", newDurationInHours); command.Parameters.Should().Contain("@p3", DapperTestContext.FrozenTime); @@ -218,7 +218,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); } @@ -300,15 +300,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("todoItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingTodoItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newTodoItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(newTodoItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("durationInHours").With(value => value.Should().Be(newTodoItem.DurationInHours)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(existingTodoItem.CreatedAt)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("modifiedAt").With(value => value.Should().Be(DapperTestContext.FrozenTime)); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("owner", "assignee", "tags"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newTodoItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(newTodoItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("durationInHours").WhoseValue.Should().Be(newTodoItem.DurationInHours); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(existingTodoItem.CreatedAt); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("modifiedAt").WhoseValue.Should().Be(DapperTestContext.FrozenTime); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("owner", "assignee", "tags"); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -330,15 +330,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => todoItemInDatabase.CreatedAt.Should().Be(existingTodoItem.CreatedAt); todoItemInDatabase.LastModifiedAt.Should().Be(DapperTestContext.FrozenTime); - todoItemInDatabase.Owner.ShouldNotBeNull(); + todoItemInDatabase.Owner.Should().NotBeNull(); todoItemInDatabase.Owner.Id.Should().Be(existingPerson1.Id); - todoItemInDatabase.Assignee.ShouldNotBeNull(); + todoItemInDatabase.Assignee.Should().NotBeNull(); todoItemInDatabase.Assignee.Id.Should().Be(existingPerson2.Id); - todoItemInDatabase.Tags.ShouldHaveCount(1); + todoItemInDatabase.Tags.Should().HaveCount(1); todoItemInDatabase.Tags.ElementAt(0).Id.Should().Be(existingTag.Id); }); - store.SqlCommands.ShouldHaveCount(5); + store.SqlCommands.Should().HaveCount(5); store.SqlCommands[0].With(command => { @@ -351,7 +351,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); @@ -363,7 +363,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p7 """)); - command.Parameters.ShouldHaveCount(7); + command.Parameters.Should().HaveCount(7); command.Parameters.Should().Contain("@p1", newTodoItem.Description); command.Parameters.Should().Contain("@p2", newTodoItem.Priority); command.Parameters.Should().Contain("@p3", newTodoItem.DurationInHours); @@ -381,7 +381,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" IN (@p2, @p3) """)); - command.Parameters.ShouldHaveCount(3); + command.Parameters.Should().HaveCount(3); command.Parameters.Should().Contain("@p1", null); command.Parameters.Should().Contain("@p2", existingTodoItem.Tags.ElementAt(0).Id); command.Parameters.Should().Contain("@p3", existingTodoItem.Tags.ElementAt(1).Id); @@ -395,7 +395,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE "Id" = @p2 """)); - command.Parameters.ShouldHaveCount(2); + command.Parameters.Should().HaveCount(2); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); command.Parameters.Should().Contain("@p2", existingTag.Id); }); @@ -408,7 +408,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WHERE t1."Id" = @p1 """)); - command.Parameters.ShouldHaveCount(1); + command.Parameters.Should().HaveCount(1); command.Parameters.Should().Contain("@p1", existingTodoItem.Id); }); } diff --git a/test/DapperTests/IntegrationTests/Sql/SubQueryInJoinTests.cs b/test/DapperTests/IntegrationTests/Sql/SubQueryInJoinTests.cs index e9b2b001a5..8b7d18d2d2 100644 --- a/test/DapperTests/IntegrationTests/Sql/SubQueryInJoinTests.cs +++ b/test/DapperTests/IntegrationTests/Sql/SubQueryInJoinTests.cs @@ -44,7 +44,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -93,7 +93,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -191,7 +191,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -244,7 +244,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -361,7 +361,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -415,7 +415,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -472,7 +472,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -531,7 +531,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { @@ -592,7 +592,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - store.SqlCommands.ShouldHaveCount(2); + store.SqlCommands.Should().HaveCount(2); store.SqlCommands[0].With(command => { diff --git a/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs b/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs index e4f16dbb1f..eeca3cdb89 100644 --- a/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs +++ b/test/DiscoveryTests/ServiceDiscoveryFacadeTests.cs @@ -8,7 +8,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using TestBuildingBlocks; using Xunit; namespace DiscoveryTests; @@ -37,10 +36,10 @@ public void Can_add_resources_from_assembly_to_graph() var resourceGraph = serviceProvider.GetRequiredService(); ResourceType? personType = resourceGraph.FindResourceType(typeof(Person)); - personType.ShouldNotBeNull(); + personType.Should().NotBeNull(); ResourceType? todoItemType = resourceGraph.FindResourceType(typeof(TodoItem)); - todoItemType.ShouldNotBeNull(); + todoItemType.Should().NotBeNull(); } [Fact] @@ -57,7 +56,7 @@ public void Can_add_resource_from_current_assembly_to_graph() var resourceGraph = serviceProvider.GetRequiredService(); ResourceType? resourceType = resourceGraph.FindResourceType(typeof(PrivateResource)); - resourceType.ShouldNotBeNull(); + resourceType.Should().NotBeNull(); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/ArchiveTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/ArchiveTests.cs index b80d7c3e3c..97506ec5d6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/ArchiveTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Archiving/ArchiveTests.cs @@ -44,9 +44,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(broadcast.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(broadcast.ArchivedAt)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(broadcast.ArchivedAt); } [Fact] @@ -70,9 +70,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(broadcast.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -97,9 +97,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(broadcasts[1].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -124,12 +124,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(broadcasts[0].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(broadcasts[0].ArchivedAt)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(broadcasts[0].ArchivedAt); responseDocument.Data.ManyValue[1].Id.Should().Be(broadcasts[1].StringId); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -154,12 +154,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(station.StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Included[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -184,14 +184,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(station.StringId); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Id.Should().Be(station.Broadcasts.ElementAt(0).StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(station.Broadcasts.ElementAt(0).ArchivedAt)); + responseDocument.Included[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(station.Broadcasts.ElementAt(0).ArchivedAt); responseDocument.Included[1].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Included[1].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -215,9 +215,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(comment.AppliesTo.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(comment.AppliesTo.ArchivedAt)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(comment.AppliesTo.ArchivedAt); } [Fact] @@ -242,9 +242,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -271,12 +271,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DateTimeOffset archivedAt0 = station.Broadcasts.ElementAt(0).ArchivedAt!.Value; - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(station.Broadcasts.ElementAt(0).StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(archivedAt0)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(archivedAt0); responseDocument.Data.ManyValue[1].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -302,12 +302,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(network.Stations.ElementAt(0).StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(network.Stations.ElementAt(0).Broadcasts.ElementAt(1).StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Included[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -335,14 +335,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DateTimeOffset archivedAt0 = network.Stations.ElementAt(0).Broadcasts.ElementAt(0).ArchivedAt!.Value; - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(network.Stations.ElementAt(0).StringId); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Id.Should().Be(network.Stations.ElementAt(0).Broadcasts.ElementAt(0).StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().Be(archivedAt0)); + responseDocument.Included[0].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().Be(archivedAt0); responseDocument.Included[1].Id.Should().Be(network.Stations.ElementAt(0).Broadcasts.ElementAt(1).StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Included[1].Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -367,7 +367,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); } @@ -393,7 +393,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(station.Broadcasts.ElementAt(0).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(station.Broadcasts.ElementAt(1).StringId); } @@ -425,10 +425,10 @@ public async Task Can_create_unarchived_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newBroadcast.Title)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("airedAt").With(value => value.Should().Be(newBroadcast.AiredAt)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("archivedAt").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newBroadcast.Title); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("airedAt").WhoseValue.Should().Be(newBroadcast.AiredAt); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("archivedAt").WhoseValue.Should().BeNull(); } [Fact] @@ -459,7 +459,7 @@ public async Task Cannot_create_archived_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -591,7 +591,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -650,7 +650,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicCustomConstrainedOperationsControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicCustomConstrainedOperationsControllerTests.cs index 3cdf4f20c0..b515ff7c13 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicCustomConstrainedOperationsControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicCustomConstrainedOperationsControllerTests.cs @@ -65,7 +65,7 @@ public async Task Can_create_resources_for_matching_resource_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); } [Fact] @@ -98,13 +98,13 @@ public async Task Cannot_create_resource_for_inaccessible_operation() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("The requested operation is not accessible."); error.Detail.Should().Be("The 'add' resource operation is not accessible for resource type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -147,13 +147,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("The requested operation is not accessible."); error.Detail.Should().Be("The 'update' resource operation is not accessible for resource type 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -203,13 +203,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("The requested operation is not accessible."); error.Detail.Should().Be("The 'add' relationship operation is not accessible for relationship 'performers' on resource type 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicDefaultConstrainedOperationsControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicDefaultConstrainedOperationsControllerTests.cs index 0b60bfe782..bec1bdc883 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicDefaultConstrainedOperationsControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Controllers/AtomicDefaultConstrainedOperationsControllerTests.cs @@ -55,13 +55,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("The requested operation is not accessible."); error.Detail.Should().Be("The 'remove' resource operation is not accessible for resource type 'textLanguages'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -147,27 +147,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(3); + responseDocument.Errors.Should().HaveCount(3); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.Forbidden); error1.Title.Should().Be("The requested operation is not accessible."); error1.Detail.Should().Be("The 'update' relationship operation is not accessible for relationship 'lyrics' on resource type 'textLanguages'."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.Forbidden); error2.Title.Should().Be("The requested operation is not accessible."); error2.Detail.Should().Be("The 'add' relationship operation is not accessible for relationship 'lyrics' on resource type 'textLanguages'."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[1]"); ErrorObject error3 = responseDocument.Errors[2]; error3.StatusCode.Should().Be(HttpStatusCode.Forbidden); error3.Title.Should().Be("The requested operation is not accessible."); error3.Detail.Should().Be("The 'remove' relationship operation is not accessible for relationship 'lyrics' on resource type 'textLanguages'."); - error3.Source.ShouldNotBeNull(); + error3.Source.Should().NotBeNull(); error3.Source.Pointer.Should().Be("/atomic:operations[2]"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs index 2438aca27a..c4f70fe60d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs @@ -65,17 +65,17 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName)); - resource.Attributes.ShouldContainKey("bornAt").With(value => value.Should().Be(newBornAt)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName); + resource.Attributes.Should().ContainKey("bornAt").WhoseValue.Should().Be(newBornAt); resource.Relationships.Should().BeNull(); }); - int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -128,33 +128,30 @@ public async Task Can_create_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(elementCount); + responseDocument.Results.Should().HaveCount(elementCount); for (int index = 0; index < elementCount; index++) { - responseDocument.Results[index].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[index].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.ShouldNotBeNull(); + resource.Should().NotBeNull(); resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTracks[index].Title)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTracks[index].Title); + resource.Attributes.Should().ContainKey("lengthInSeconds").WhoseValue.As().Should().BeApproximately(newTracks[index].LengthInSeconds); + resource.Attributes.Should().ContainKey("genre").WhoseValue.Should().Be(newTracks[index].Genre); + resource.Attributes.Should().ContainKey("releasedAt").WhoseValue.Should().Be(newTracks[index].ReleasedAt); - resource.Attributes.ShouldContainKey("lengthInSeconds") - .With(value => value.As().Should().BeApproximately(newTracks[index].LengthInSeconds)); - - resource.Attributes.ShouldContainKey("genre").With(value => value.Should().Be(newTracks[index].Genre)); - resource.Attributes.ShouldContainKey("releasedAt").With(value => value.Should().Be(newTracks[index].ReleasedAt)); - - resource.Relationships.ShouldNotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); } - Guid[] newTrackIds = responseDocument.Results.Select(result => Guid.Parse(result.Data.SingleValue!.Id.ShouldNotBeNull())).ToArray(); + Guid[] newTrackIds = responseDocument.Results.Select(result => Guid.Parse(result.Data.SingleValue!.Id.Should().NotBeNull().And.Subject)).ToArray(); await _testContext.RunOnDatabaseAsync(async dbContext => { List tracksInDatabase = await dbContext.MusicTracks.Where(musicTrack => newTrackIds.Contains(musicTrack.Id)).ToListAsync(); - tracksInDatabase.ShouldHaveCount(elementCount); + tracksInDatabase.Should().HaveCount(elementCount); for (int index = 0; index < elementCount; index++) { @@ -201,17 +198,17 @@ public async Task Can_create_resource_without_attributes_or_relationships() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().BeNull()); - resource.Attributes.ShouldContainKey("bornAt").With(value => value.Should().Be(default(DateTimeOffset))); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().BeNull(); + resource.Attributes.Should().ContainKey("bornAt").WhoseValue.Should().Be(default(DateTimeOffset)); resource.Relationships.Should().BeNull(); }); - int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -256,15 +253,15 @@ public async Task Cannot_create_resource_with_unknown_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown attribute found."); error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'playlists'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -304,16 +301,16 @@ public async Task Can_create_resource_with_unknown_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newName)); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newName); + resource.Relationships.Should().NotBeEmpty(); }); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -361,15 +358,15 @@ public async Task Cannot_create_resource_with_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'lyrics'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -419,22 +416,22 @@ public async Task Can_create_resource_with_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("lyrics"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - long newLyricId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + long newLyricId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.FirstWithIdAsync(newLyricId); - lyricInDatabase.ShouldNotBeNull(); + lyricInDatabase.Should().NotBeNull(); }); } @@ -473,15 +470,15 @@ public async Task Cannot_create_resource_with_client_generated_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: The use of client-generated IDs is disabled."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -508,15 +505,15 @@ public async Task Cannot_create_resource_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -546,15 +543,15 @@ public async Task Cannot_create_resource_for_ref_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'relationship' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -580,15 +577,15 @@ public async Task Cannot_create_resource_for_missing_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -615,15 +612,15 @@ public async Task Cannot_create_resource_for_null_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -662,15 +659,15 @@ public async Task Cannot_create_resource_for_array_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -702,15 +699,15 @@ public async Task Cannot_create_resource_for_missing_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -740,15 +737,15 @@ public async Task Cannot_create_resource_for_unknown_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -785,15 +782,15 @@ public async Task Cannot_create_resource_with_readonly_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute is read-only."); error.Detail.Should().Be("Attribute 'isArchived' on resource type 'playlists' is read-only."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/isArchived"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -827,15 +824,15 @@ public async Task Cannot_create_resource_with_incompatible_attribute_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible attribute value found."); error.Detail.Should().Be("Failed to convert attribute 'bornAt' with value '12345' of type 'Number' to type 'DateTimeOffset'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/bornAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -911,16 +908,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTitle)); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTitle); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -938,13 +935,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTitle); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingPerformer.Id); }); } @@ -980,14 +977,14 @@ public async Task Cannot_assign_attribute_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute value cannot be assigned when creating resource."); error.Detail.Should().Be("The attribute 'createdAt' on resource type 'lyrics' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/createdAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs index e20d8d45ff..8675f54c3d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs @@ -73,14 +73,14 @@ public async Task Can_create_resource_with_client_generated_guid_ID_having_side_ string isoCode = $"{newLanguage.IsoCode}{ImplicitlyChangingTextLanguageDefinition.Suffix}"; - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("textLanguages"); - resource.Attributes.ShouldContainKey("isoCode").With(value => value.Should().Be(isoCode)); + resource.Attributes.Should().ContainKey("isoCode").WhoseValue.Should().Be(isoCode); resource.Attributes.Should().NotContainKey("isRightToLeft"); - resource.Relationships.ShouldNotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -183,16 +183,16 @@ public async Task Can_create_resource_for_missing_client_generated_ID_having_sid string isoCode = $"{newIsoCode}{ImplicitlyChangingTextLanguageDefinition.Suffix}"; - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("textLanguages"); - resource.Attributes.ShouldContainKey("isoCode").With(value => value.Should().Be(isoCode)); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().ContainKey("isoCode").WhoseValue.Should().Be(isoCode); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newLanguageId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newLanguageId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -239,15 +239,15 @@ public async Task Cannot_create_resource_for_missing_client_generated_ID(ClientI // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -299,13 +299,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Another resource with the specified ID already exists."); error.Detail.Should().Be($"Another resource of type 'textLanguages' with ID '{languageToCreate.StringId}' already exists."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -348,15 +348,15 @@ public async Task Cannot_create_resource_for_incompatible_ID(ClientIdGenerationM // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int32'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -397,16 +397,16 @@ public async Task Can_create_resource_with_local_ID(ClientIdGenerationMode mode) // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTitle); resource.Relationships.Should().BeNull(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -448,15 +448,15 @@ public async Task Cannot_create_resource_with_local_ID(ClientIdGenerationMode mo // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'lid' element cannot be used because a client-generated ID is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/lid"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -493,14 +493,14 @@ public async Task Cannot_create_resource_for_ID_and_local_ID(ClientIdGenerationM // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs index 0d4d367c12..775b6d2197 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs @@ -83,22 +83,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(newTrackId); - trackInDatabase.Performers.ShouldHaveCount(2); + trackInDatabase.Performers.Should().HaveCount(2); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[0].Id); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[1].Id); }); @@ -168,22 +168,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(newPlaylistId); - playlistInDatabase.Tracks.ShouldHaveCount(3); + playlistInDatabase.Tracks.Should().HaveCount(3); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[1].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[2].Id); @@ -230,15 +230,15 @@ public async Task Cannot_create_for_missing_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -282,15 +282,15 @@ public async Task Cannot_create_for_unknown_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -333,15 +333,15 @@ public async Task Cannot_create_for_missing_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -399,13 +399,13 @@ public async Task Cannot_create_for_unknown_relationship_IDs() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); error1.Title.Should().Be("A related resource does not exist."); error1.Detail.Should().Be($"Related resource of type 'performers' with ID '{performerId1}' in relationship 'performers' does not exist."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); error1.Meta.Should().NotContainKey("requestBody"); @@ -413,7 +413,7 @@ public async Task Cannot_create_for_unknown_relationship_IDs() error2.StatusCode.Should().Be(HttpStatusCode.NotFound); error2.Title.Should().Be("A related resource does not exist."); error2.Detail.Should().Be($"Related resource of type 'performers' with ID '{performerId2}' in relationship 'performers' does not exist."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]"); error2.Meta.Should().NotContainKey("requestBody"); } @@ -459,15 +459,15 @@ public async Task Cannot_create_on_relationship_type_mismatch() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -529,22 +529,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(newTrackId); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingPerformer.Id); }); } @@ -582,15 +582,15 @@ public async Task Cannot_create_with_missing_data_in_OneToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -627,15 +627,15 @@ public async Task Cannot_create_with_null_data_in_ManyToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -674,15 +674,15 @@ public async Task Cannot_create_with_object_data_in_ManyToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -726,14 +726,14 @@ public async Task Cannot_assign_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/occursIn"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs index a522105806..ff60ccbf87 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs @@ -77,22 +77,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("lyrics"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - long newLyricId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + long newLyricId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.Include(lyric => lyric.Track).FirstWithIdAsync(newLyricId); - lyricInDatabase.Track.ShouldNotBeNull(); + lyricInDatabase.Track.Should().NotBeNull(); lyricInDatabase.Track.Id.Should().Be(existingTrack.Id); }); } @@ -148,22 +148,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Lyric).FirstWithIdAsync(newTrackId); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); }); } @@ -225,18 +225,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(elementCount); + responseDocument.Results.Should().HaveCount(elementCount); for (int index = 0; index < elementCount; index++) { - responseDocument.Results[index].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[index].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitles[index])); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitles[index]); }); } - Guid[] newTrackIds = responseDocument.Results.Select(result => Guid.Parse(result.Data.SingleValue!.Id.ShouldNotBeNull())).ToArray(); + Guid[] newTrackIds = responseDocument.Results.Select(result => Guid.Parse(result.Data.SingleValue!.Id.Should().NotBeNull().And.Subject)).ToArray(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -251,7 +251,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - tracksInDatabase.ShouldHaveCount(elementCount); + tracksInDatabase.Should().HaveCount(elementCount); for (int index = 0; index < elementCount; index++) { @@ -259,7 +259,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitles[index]); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); } }); @@ -296,15 +296,15 @@ public async Task Cannot_create_for_null_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -340,15 +340,15 @@ public async Task Cannot_create_for_missing_data_in_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -392,15 +392,15 @@ public async Task Cannot_create_for_array_data_in_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -440,15 +440,15 @@ public async Task Cannot_create_for_missing_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -489,15 +489,15 @@ public async Task Cannot_create_for_unknown_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -537,15 +537,15 @@ public async Task Cannot_create_for_missing_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -594,13 +594,13 @@ public async Task Cannot_create_with_unknown_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'lyrics' with ID '{lyricId}' in relationship 'lyric' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -643,15 +643,15 @@ public async Task Cannot_create_on_relationship_type_mismatch() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -715,22 +715,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); - resource.Attributes.ShouldNotBeEmpty(); - resource.Relationships.ShouldNotBeEmpty(); + resource.Attributes.Should().NotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(newTrackId); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); }); } @@ -773,14 +773,14 @@ public async Task Cannot_assign_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/language"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs index cbc3280aed..c8c00b1a54 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs @@ -319,7 +319,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => MusicTrack? trackInDatabase = await dbContext.MusicTracks.FirstWithIdOrDefaultAsync(existingPlaylist.Tracks[0].Id); - trackInDatabase.ShouldNotBeNull(); + trackInDatabase.Should().NotBeNull(); }); } @@ -347,15 +347,15 @@ public async Task Cannot_delete_resource_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -381,15 +381,15 @@ public async Task Cannot_delete_resource_for_missing_ref_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'ref' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -419,15 +419,15 @@ public async Task Cannot_delete_resource_for_missing_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -458,15 +458,15 @@ public async Task Cannot_delete_resource_for_unknown_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -496,15 +496,15 @@ public async Task Cannot_delete_resource_for_missing_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -537,13 +537,13 @@ public async Task Cannot_delete_resource_for_unknown_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'performers' with ID '{performerId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -578,15 +578,15 @@ public async Task Cannot_delete_resource_for_incompatible_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int64'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -618,14 +618,14 @@ public async Task Cannot_delete_resource_for_ID_and_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs index 4686e55244..24423438bc 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicAbsoluteLinksTests.cs @@ -80,37 +80,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { string languageLink = $"{HostPrefix}/textLanguages/{existingLanguage.StringId}"; - resource.ShouldNotBeNull(); - resource.Links.ShouldNotBeNull(); + resource.Should().NotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(languageLink); - resource.Relationships.ShouldContainKey("lyrics").With(value => + resource.Relationships.Should().ContainKey("lyrics").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{languageLink}/relationships/lyrics"); value.Links.Related.Should().Be($"{languageLink}/lyrics"); }); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { string companyLink = $"{HostPrefix}/recordCompanies/{existingCompany.StringId}"; - resource.ShouldNotBeNull(); - resource.Links.ShouldNotBeNull(); + resource.Should().NotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(companyLink); - resource.Relationships.ShouldContainKey("tracks").With(value => + resource.Relationships.Should().ContainKey("tracks").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{companyLink}/relationships/tracks"); value.Links.Related.Should().Be($"{companyLink}/tracks"); }); @@ -156,11 +156,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.ShouldNotBeNull(); + resource.Should().NotBeNull(); resource.Links.Should().BeNull(); resource.Relationships.Should().BeNull(); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicRelativeLinksWithNamespaceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicRelativeLinksWithNamespaceTests.cs index 86b8ad9846..6d5bd1797e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicRelativeLinksWithNamespaceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Links/AtomicRelativeLinksWithNamespaceTests.cs @@ -73,39 +73,39 @@ public async Task Create_resource_with_side_effects_returns_relative_links() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull(); + responseDocument.Results[0].Data.SingleValue.Should().NotBeNull(); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - string languageLink = $"/api/textLanguages/{Guid.Parse(resource.Id.ShouldNotBeNull())}"; + string languageLink = $"/api/textLanguages/{Guid.Parse(resource.Id.Should().NotBeNull().And.Subject)}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(languageLink); - resource.Relationships.ShouldContainKey("lyrics").With(value => + resource.Relationships.Should().ContainKey("lyrics").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{languageLink}/relationships/lyrics"); value.Links.Related.Should().Be($"{languageLink}/lyrics"); }); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull(); + responseDocument.Results[1].Data.SingleValue.Should().NotBeNull(); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - string companyLink = $"/api/recordCompanies/{short.Parse(resource.Id.ShouldNotBeNull())}"; + string companyLink = $"/api/recordCompanies/{short.Parse(resource.Id.Should().NotBeNull().And.Subject)}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(companyLink); - resource.Relationships.ShouldContainKey("tracks").With(value => + resource.Relationships.Should().ContainKey("tracks").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{companyLink}/relationships/tracks"); value.Links.Related.Should().Be($"{companyLink}/tracks"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs index e65b218764..fb02b6df3f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/LocalIds/AtomicLocalIdTests.cs @@ -80,25 +80,25 @@ public async Task Can_create_resource_with_ManyToOne_relationship_using_local_ID // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("recordCompanies"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newCompany.Name)); - resource.Attributes.ShouldContainKey("countryOfResidence").With(value => value.Should().Be(newCompany.CountryOfResidence)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newCompany.Name); + resource.Attributes.Should().ContainKey("countryOfResidence").WhoseValue.Should().Be(newCompany.CountryOfResidence); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - short newCompanyId = short.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + short newCompanyId = short.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -106,7 +106,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(newCompanyId); trackInDatabase.OwnedBy.Name.Should().Be(newCompany.Name); trackInDatabase.OwnedBy.CountryOfResidence.Should().Be(newCompany.CountryOfResidence); @@ -177,25 +177,25 @@ public async Task Can_create_resource_with_OneToMany_relationship_using_local_ID // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newPerformer.ArtistName)); - resource.Attributes.ShouldContainKey("bornAt").With(value => value.Should().Be(newPerformer.BornAt)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newPerformer.ArtistName); + resource.Attributes.Should().ContainKey("bornAt").WhoseValue.Should().Be(newPerformer.BornAt); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + int newPerformerId = int.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -203,7 +203,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(newPerformerId); trackInDatabase.Performers[0].ArtistName.Should().Be(newPerformer.ArtistName); trackInDatabase.Performers[0].BornAt.Should().Be(newPerformer.BornAt); @@ -273,24 +273,24 @@ public async Task Can_create_resource_with_ManyToMany_relationship_using_local_I // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newPlaylistName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newPlaylistName); }); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - long newPlaylistId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + long newPlaylistId = long.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -298,7 +298,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => playlistInDatabase.Name.Should().Be(newPlaylistName); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(newTrackId); playlistInDatabase.Tracks[0].Title.Should().Be(newTrackTitle); }); @@ -360,13 +360,13 @@ public async Task Cannot_consume_local_ID_that_is_assigned_in_same_operation() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Local ID cannot be both defined and used within the same operation."); error.Detail.Should().Be("Local ID 'company-1' cannot be both defined and used within the same operation."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -427,13 +427,13 @@ public async Task Cannot_reassign_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Another local ID with the same name is already defined at this point."); error.Detail.Should().Be("Another local ID with name 'playlist-1' is already defined at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } @@ -487,19 +487,19 @@ public async Task Can_update_resource_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); - resource.Attributes.ShouldContainKey("genre").With(value => value.Should().BeNull()); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); + resource.Attributes.Should().ContainKey("genre").WhoseValue.Should().BeNull(); }); responseDocument.Results[1].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -607,34 +607,34 @@ public async Task Can_update_resource_with_relationships_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(4); + responseDocument.Results.Should().HaveCount(4); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName); }); - responseDocument.Results[2].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[2].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("recordCompanies"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newCompanyName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newCompanyName); }); responseDocument.Results[3].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); - short newCompanyId = short.Parse(responseDocument.Results[2].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + short newCompanyId = short.Parse(responseDocument.Results[2].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -651,10 +651,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(newCompanyId); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(newPerformerId); trackInDatabase.Performers[0].ArtistName.Should().Be(newArtistName); }); @@ -726,26 +726,26 @@ public async Task Can_create_ManyToOne_relationship_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("recordCompanies"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newCompanyName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newCompanyName); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - short newCompanyId = short.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + short newCompanyId = short.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -753,7 +753,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(newCompanyId); trackInDatabase.OwnedBy.Name.Should().Be(newCompanyName); }); @@ -828,26 +828,26 @@ public async Task Can_create_OneToMany_relationship_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -855,7 +855,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(newPerformerId); trackInDatabase.Performers[0].ArtistName.Should().Be(newArtistName); }); @@ -930,26 +930,26 @@ public async Task Can_create_ManyToMany_relationship_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newPlaylistName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newPlaylistName); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -957,7 +957,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => playlistInDatabase.Name.Should().Be(newPlaylistName); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(newTrackId); playlistInDatabase.Tracks[0].Title.Should().Be(newTrackTitle); }); @@ -1054,26 +1054,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1081,7 +1081,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(newPerformerId); trackInDatabase.Performers[0].ArtistName.Should().Be(newArtistName); }); @@ -1178,26 +1178,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newPlaylistName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newPlaylistName); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1205,7 +1205,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => playlistInDatabase.Name.Should().Be(newPlaylistName); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(newTrackId); playlistInDatabase.Tracks[0].Title.Should().Be(newTrackTitle); }); @@ -1302,26 +1302,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(3); + responseDocument.Results.Should().HaveCount(3); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName); }); responseDocument.Results[2].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + int newPerformerId = int.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1329,7 +1329,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.Performers.ShouldHaveCount(2); + trackInDatabase.Performers.Should().HaveCount(2); trackInDatabase.Performers[0].Id.Should().Be(existingPerformer.Id); trackInDatabase.Performers[0].ArtistName.Should().Be(existingPerformer.ArtistName); @@ -1448,28 +1448,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(4); + responseDocument.Results.Should().HaveCount(4); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("playlists"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newPlaylistName)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newPlaylistName); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[2].Data.Value.Should().BeNull(); responseDocument.Results[3].Data.Value.Should().BeNull(); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); - Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); + Guid newTrackId = Guid.Parse(responseDocument.Results[1].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1477,7 +1477,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => playlistInDatabase.Name.Should().Be(newPlaylistName); - playlistInDatabase.Tracks.ShouldHaveCount(3); + playlistInDatabase.Tracks.Should().HaveCount(3); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[1].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == newTrackId); @@ -1605,32 +1605,32 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(4); + responseDocument.Results.Should().HaveCount(4); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName1)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName1); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("performers"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("artistName").With(value => value.Should().Be(newArtistName2)); + resource.Attributes.Should().ContainKey("artistName").WhoseValue.Should().Be(newArtistName2); }); - responseDocument.Results[2].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[2].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[3].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[2].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[2].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1638,7 +1638,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(newTrackTitle); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingPerformer.Id); trackInDatabase.Performers[0].ArtistName.Should().Be(existingPerformer.ArtistName); }); @@ -1743,13 +1743,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(4); + responseDocument.Results.Should().HaveCount(4); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[1].Data.Value.Should().BeNull(); @@ -1762,7 +1762,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(existingPlaylist.Tracks[0].Id); }); } @@ -1812,18 +1812,18 @@ public async Task Can_delete_resource_using_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("musicTracks"); resource.Lid.Should().BeNull(); - resource.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTrackTitle)); + resource.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTrackTitle); }); responseDocument.Results[1].Data.Value.Should().BeNull(); - Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + Guid newTrackId = Guid.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1870,13 +1870,13 @@ public async Task Cannot_consume_unassigned_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Server-generated value for local ID is not available at this point."); error.Detail.Should().Be($"Server-generated value for local ID '{Unknown.LocalId}' is not available at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -1920,13 +1920,13 @@ public async Task Cannot_consume_unassigned_local_ID_in_data_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Server-generated value for local ID is not available at this point."); error.Detail.Should().Be($"Server-generated value for local ID '{Unknown.LocalId}' is not available at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -1984,13 +1984,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Server-generated value for local ID is not available at this point."); error.Detail.Should().Be($"Server-generated value for local ID '{Unknown.LocalId}' is not available at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -2047,13 +2047,13 @@ public async Task Cannot_consume_unassigned_local_ID_in_relationship_data_elemen // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Server-generated value for local ID is not available at this point."); error.Detail.Should().Be($"Server-generated value for local ID '{Unknown.LocalId}' is not available at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -2113,13 +2113,13 @@ public async Task Cannot_consume_unassigned_local_ID_in_relationship_data_array( // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Server-generated value for local ID is not available at this point."); error.Detail.Should().Be($"Server-generated value for local ID '{Unknown.LocalId}' is not available at this point."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -2178,13 +2178,13 @@ public async Task Cannot_consume_local_ID_of_different_type_in_same_operation() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'track-1' belongs to resource type 'musicTracks' instead of 'recordCompanies'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); } @@ -2242,13 +2242,13 @@ public async Task Cannot_consume_local_ID_of_different_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'company-1' belongs to resource type 'recordCompanies' instead of 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } @@ -2303,13 +2303,13 @@ public async Task Cannot_consume_local_ID_of_different_type_in_data_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'performer-1' belongs to resource type 'performers' instead of 'playlists'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } @@ -2384,13 +2384,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'company-1' belongs to resource type 'recordCompanies' instead of 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } @@ -2463,13 +2463,13 @@ public async Task Cannot_consume_local_ID_of_different_type_in_relationship_data // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'playlist-1' belongs to resource type 'playlists' instead of 'recordCompanies'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } @@ -2539,13 +2539,13 @@ public async Task Cannot_consume_local_ID_of_different_type_in_relationship_data // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Incompatible type in Local ID usage."); error.Detail.Should().Be("Local ID 'performer-1' belongs to resource type 'performers' instead of 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[2]"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs index 4d4982f732..1ab1d848ac 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResourceMetaTests.cs @@ -83,24 +83,24 @@ public async Task Returns_resource_meta_in_create_resource_with_side_effects() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Meta.ShouldHaveCount(1); + resource.Meta.Should().HaveCount(1); - resource.Meta.ShouldContainKey("copyright").With(value => + resource.Meta.Should().ContainKey("copyright").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("(C) 2018. All rights reserved."); }); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Meta.ShouldHaveCount(1); + resource.Meta.Should().HaveCount(1); - resource.Meta.ShouldContainKey("copyright").With(value => + resource.Meta.Should().ContainKey("copyright").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("(C) 1994. All rights reserved."); @@ -155,13 +155,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Meta.ShouldHaveCount(1); + resource.Meta.Should().HaveCount(1); - resource.Meta.ShouldContainKey("notice").With(value => + resource.Meta.Should().ContainKey("notice").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be(TextLanguageMetaDefinition.NoticeText); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs index 88e7115f66..b111ee47fb 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Meta/AtomicResponseMetaTests.cs @@ -60,26 +60,26 @@ public async Task Returns_top_level_meta_in_create_resource_with_side_effects() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Meta.ShouldHaveCount(3); + responseDocument.Meta.Should().HaveCount(3); - responseDocument.Meta.ShouldContainKey("license").With(value => + responseDocument.Meta.Should().ContainKey("license").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("MIT"); }); - responseDocument.Meta.ShouldContainKey("projectUrl").With(value => + responseDocument.Meta.Should().ContainKey("projectUrl").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("https://github.com/json-api-dotnet/JsonApiDotNetCore/"); }); - responseDocument.Meta.ShouldContainKey("versions").With(value => + responseDocument.Meta.Should().ContainKey("versions").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; string?[] versionArray = element.EnumerateArray().Select(arrayItem => arrayItem.GetString()).ToArray(); - versionArray.ShouldHaveCount(4); + versionArray.Should().HaveCount(4); versionArray.Should().Contain("v4.0.0"); versionArray.Should().Contain("v3.1.0"); versionArray.Should().Contain("v2.5.2"); @@ -126,26 +126,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Meta.ShouldHaveCount(3); + responseDocument.Meta.Should().HaveCount(3); - responseDocument.Meta.ShouldContainKey("license").With(value => + responseDocument.Meta.Should().ContainKey("license").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("MIT"); }); - responseDocument.Meta.ShouldContainKey("projectUrl").With(value => + responseDocument.Meta.Should().ContainKey("projectUrl").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("https://github.com/json-api-dotnet/JsonApiDotNetCore/"); }); - responseDocument.Meta.ShouldContainKey("versions").With(value => + responseDocument.Meta.Should().ContainKey("versions").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; string?[] versionArray = element.EnumerateArray().Select(arrayItem => arrayItem.GetString()).ToArray(); - versionArray.ShouldHaveCount(4); + versionArray.Should().HaveCount(4); versionArray.Should().Contain("v4.0.0"); versionArray.Should().Contain("v3.1.0"); versionArray.Should().Contain("v2.5.2"); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicLoggingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicLoggingTests.cs index 34618f95f8..1662f9387f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicLoggingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicLoggingTests.cs @@ -67,13 +67,13 @@ public async Task Logs_unhandled_exception_at_Error_level() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.InternalServerError); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.InternalServerError); error.Title.Should().Be("An unhandled error occurred while processing an operation in this request."); error.Detail.Should().Be("Simulated failure."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); IReadOnlyList logMessages = loggerProvider.GetMessages(); @@ -111,7 +111,7 @@ public async Task Logs_invalid_request_body_error_at_Information_level() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); IReadOnlyList logMessages = loggerProvider.GetMessages(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs index bedb5d7da2..e4d67f457f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs @@ -30,10 +30,10 @@ public async Task Cannot_process_for_missing_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.AtomicOperations.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -57,14 +57,14 @@ public async Task Cannot_process_for_null_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -81,7 +81,7 @@ public async Task Cannot_process_for_broken_JSON_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); @@ -110,14 +110,14 @@ public async Task Cannot_process_for_missing_operations_array() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: No operations found."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -137,14 +137,14 @@ public async Task Cannot_process_empty_operations_array() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: No operations found."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -167,15 +167,15 @@ public async Task Cannot_process_null_operation() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -208,7 +208,7 @@ public async Task Cannot_process_for_unknown_operation_code() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs index f24e25a216..0173e1c6d4 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs @@ -65,15 +65,15 @@ public async Task Cannot_process_more_operations_than_maximum() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Too many operations in request."); error.Detail.Should().Be("The number of operations in this request (3) is higher than the maximum of 2."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs index 09596c2f00..18e7640d22 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ModelStateValidation/AtomicModelStateValidationTests.cs @@ -51,20 +51,20 @@ public async Task Cannot_create_resource_with_multiple_violations() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Title field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/title"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The field LengthInSeconds must be between 1 and 1440."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/lengthInSeconds"); } @@ -104,13 +104,13 @@ public async Task Cannot_create_resource_when_violation_from_custom_ValidationAt // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("ReleasedAt must be in the past."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/releasedAt"); } @@ -168,15 +168,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().Id.ShouldNotBeNull()); + long newPlaylistId = long.Parse(responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(newPlaylistId); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(existingTrack.Id); }); } @@ -222,20 +222,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Title field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/title"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The field LengthInSeconds must be between 1 and 1440."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/lengthInSeconds"); } @@ -348,7 +348,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(existingTrack.Id); }); } @@ -402,7 +402,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); }); } @@ -459,7 +459,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(existingTrack.Id); }); } @@ -509,20 +509,20 @@ public async Task Validates_all_operations_before_execution_starts() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Name field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/name"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The field LengthInSeconds must be between 1 and 1440."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[1]/data/attributes/lengthInSeconds"); } @@ -593,7 +593,7 @@ public async Task Does_not_exceed_MaxModelValidationErrors() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(3); + responseDocument.Errors.Should().HaveCount(3); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); @@ -605,14 +605,14 @@ public async Task Does_not_exceed_MaxModelValidationErrors() error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The Name field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/name"); ErrorObject error3 = responseDocument.Errors[2]; error3.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error3.Title.Should().Be("Input validation failed."); error3.Detail.Should().Be("The Name field is required."); - error3.Source.ShouldNotBeNull(); + error3.Source.Should().NotBeNull(); error3.Source.Pointer.Should().Be("/atomic:operations[1]/data/attributes/name"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs index e979e164c9..a635e12fb6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/QueryStrings/AtomicQueryStringTests.cs @@ -53,13 +53,13 @@ public async Task Cannot_include_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'include' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } @@ -93,13 +93,13 @@ public async Task Cannot_filter_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'filter' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -133,13 +133,13 @@ public async Task Cannot_sort_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'sort' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -173,13 +173,13 @@ public async Task Cannot_use_pagination_number_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'page[number]' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -213,13 +213,13 @@ public async Task Cannot_use_pagination_size_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'page[size]' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } @@ -253,13 +253,13 @@ public async Task Cannot_use_sparse_fieldset_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'fields[recordCompanies]' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("fields[recordCompanies]"); } @@ -290,7 +290,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(musicTracks[2].StringId); } @@ -327,7 +327,7 @@ public async Task Cannot_use_Queryable_handler_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -336,7 +336,7 @@ public async Task Cannot_use_Queryable_handler_at_operations_endpoint() error.Detail.Should().Be("Query string parameter 'isRecentlyReleased' is unknown. " + "Set 'AllowUnknownQueryStringParameters' to 'true' in options to ignore unknown parameters."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("isRecentlyReleased"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs index 8e3c2ac7f9..cb0325882e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/Serialization/AtomicSerializationResourceDefinitionTests.cs @@ -88,28 +88,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newCompanies[0].Name.ToUpperInvariant())); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newCompanies[0].Name.ToUpperInvariant()); string countryOfResidence = newCompanies[0].CountryOfResidence!.ToUpperInvariant(); - resource.Attributes.ShouldContainKey("countryOfResidence").With(value => value.Should().Be(countryOfResidence)); + resource.Attributes.Should().ContainKey("countryOfResidence").WhoseValue.Should().Be(countryOfResidence); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newCompanies[1].Name.ToUpperInvariant())); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newCompanies[1].Name.ToUpperInvariant()); string countryOfResidence = newCompanies[1].CountryOfResidence!.ToUpperInvariant(); - resource.Attributes.ShouldContainKey("countryOfResidence").With(value => value.Should().Be(countryOfResidence)); + resource.Attributes.Should().ContainKey("countryOfResidence").WhoseValue.Should().Be(countryOfResidence); }); await _testContext.RunOnDatabaseAsync(async dbContext => { List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(2); + companiesInDatabase.Should().HaveCount(2); companiesInDatabase[0].Name.Should().Be(newCompanies[0].Name.ToUpperInvariant()); companiesInDatabase[0].CountryOfResidence.Should().Be(newCompanies[0].CountryOfResidence); @@ -181,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); hitCounter.HitExtensibilityPoints.Should().BeEmpty(); } @@ -240,28 +240,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(existingCompanies[0].Name)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(existingCompanies[0].Name); string countryOfResidence = existingCompanies[0].CountryOfResidence!.ToUpperInvariant(); - resource.Attributes.ShouldContainKey("countryOfResidence").With(value => value.Should().Be(countryOfResidence)); + resource.Attributes.Should().ContainKey("countryOfResidence").WhoseValue.Should().Be(countryOfResidence); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("name").With(value => value.Should().Be(existingCompanies[1].Name)); + resource.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(existingCompanies[1].Name); string countryOfResidence = existingCompanies[1].CountryOfResidence!.ToUpperInvariant(); - resource.Attributes.ShouldContainKey("countryOfResidence").With(value => value.Should().Be(countryOfResidence)); + resource.Attributes.Should().ContainKey("countryOfResidence").WhoseValue.Should().Be(countryOfResidence); }); await _testContext.RunOnDatabaseAsync(async dbContext => { List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(2); + companiesInDatabase.Should().HaveCount(2); companiesInDatabase[0].Name.Should().Be(existingCompanies[0].Name); companiesInDatabase[0].CountryOfResidence.Should().Be(existingCompanies[0].CountryOfResidence); @@ -332,7 +332,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); hitCounter.HitExtensibilityPoints.Should().BeEmpty(); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs index 983a9c5213..9263d1ec32 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/ResourceDefinitions/SparseFieldSets/AtomicSparseFieldSetResourceDefinitionTests.cs @@ -86,17 +86,17 @@ public async Task Hides_text_in_create_resource_with_side_effects() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("format").With(value => value.Should().Be(newLyrics[0].Format)); + resource.Attributes.Should().ContainKey("format").WhoseValue.Should().Be(newLyrics[0].Format); resource.Attributes.Should().NotContainKey("text"); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("format").With(value => value.Should().Be(newLyrics[1].Format)); + resource.Attributes.Should().ContainKey("format").WhoseValue.Should().Be(newLyrics[1].Format); resource.Attributes.Should().NotContainKey("text"); }); @@ -165,17 +165,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(2); + responseDocument.Results.Should().HaveCount(2); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("format").With(value => value.Should().Be(existingLyrics[0].Format)); + resource.Attributes.Should().ContainKey("format").WhoseValue.Should().Be(existingLyrics[0].Format); resource.Attributes.Should().NotContainKey("text"); }); - responseDocument.Results[1].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Attributes.ShouldContainKey("format").With(value => value.Should().Be(existingLyrics[1].Format)); + resource.Attributes.Should().ContainKey("format").WhoseValue.Should().Be(existingLyrics[1].Format); resource.Attributes.Should().NotContainKey("text"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs index b4f393d901..f27e6c4a93 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicRollbackTests.cs @@ -88,13 +88,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'performers' with ID '{unknownPerformerId}' in relationship 'performers' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -168,13 +168,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'performers' with ID '{unknownPerformerId}' in relationship 'performers' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[1]"); await _testContext.RunOnDatabaseAsync(async dbContext => diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicTransactionConsistencyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicTransactionConsistencyTests.cs index 4b5a6afc1b..14cfc466a0 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicTransactionConsistencyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Transactions/AtomicTransactionConsistencyTests.cs @@ -64,13 +64,13 @@ public async Task Cannot_use_non_transactional_repository() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Unsupported resource type in atomic:operations request."); error.Detail.Should().Be("Operations on resources of type 'performers' cannot be used because transaction support is unavailable."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -107,13 +107,13 @@ public async Task Cannot_use_transactional_repository_without_active_transaction // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Unsupported combination of resource types in atomic:operations request."); error.Detail.Should().Be("All operations need to participate in a single shared transaction, which is not the case for this request."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -150,13 +150,13 @@ public async Task Cannot_use_distributed_transaction() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Unsupported combination of resource types in atomic:operations request."); error.Detail.Should().Be("All operations need to participate in a single shared transaction, which is not the case for this request."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs index e59b9d24d5..5ddc0d55fd 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs @@ -62,15 +62,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this operation."); error.Detail.Should().Be("Relationship 'ownedBy' is not a to-many relationship."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -146,7 +146,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(3); + trackInDatabase.Performers.Should().HaveCount(3); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingTrack.Performers[0].Id); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[0].Id); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[1].Id); @@ -226,7 +226,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(3); + playlistInDatabase.Tracks.Should().HaveCount(3); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingPlaylist.Tracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[1].Id); @@ -257,15 +257,15 @@ public async Task Cannot_add_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -296,15 +296,15 @@ public async Task Cannot_add_for_missing_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -336,15 +336,15 @@ public async Task Cannot_add_for_unknown_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -375,15 +375,15 @@ public async Task Cannot_add_for_missing_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -433,13 +433,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'recordCompanies' with ID '{companyId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -474,15 +474,15 @@ public async Task Cannot_add_for_ID_and_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -513,15 +513,15 @@ public async Task Cannot_add_for_missing_relationship_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'relationship' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -553,15 +553,15 @@ public async Task Cannot_add_for_unknown_relationship_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -601,15 +601,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -650,15 +650,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -701,15 +701,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -748,15 +748,15 @@ public async Task Cannot_add_for_missing_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -796,15 +796,15 @@ public async Task Cannot_add_for_unknown_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -843,15 +843,15 @@ public async Task Cannot_add_for_missing_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -892,15 +892,15 @@ public async Task Cannot_add_for_ID_and_local_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -959,20 +959,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); error1.Title.Should().Be("A related resource does not exist."); error1.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[0]}' in relationship 'tracks' does not exist."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.NotFound); error2.Title.Should().Be("A related resource does not exist."); error2.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[1]}' in relationship 'tracks' does not exist."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -1021,15 +1021,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1077,7 +1077,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingTrack.Performers[0].Id); }); } @@ -1124,14 +1124,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be added to."); error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be added to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs index f7bf47e989..a914e59ac3 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs @@ -62,15 +62,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this operation."); error.Detail.Should().Be("Relationship 'ownedBy' is not a to-many relationship."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -144,11 +144,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingTrack.Performers[1].Id); List performersInDatabase = await dbContext.Performers.ToListAsync(); - performersInDatabase.ShouldHaveCount(3); + performersInDatabase.Should().HaveCount(3); }); } @@ -223,12 +223,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(1); + playlistInDatabase.Tracks.Should().HaveCount(1); playlistInDatabase.Tracks[0].Id.Should().Be(existingPlaylist.Tracks[1].Id); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(3); + tracksInDatabase.Should().HaveCount(3); }); } @@ -256,15 +256,15 @@ public async Task Cannot_remove_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -295,15 +295,15 @@ public async Task Cannot_remove_for_missing_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -335,15 +335,15 @@ public async Task Cannot_remove_for_unknown_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -374,15 +374,15 @@ public async Task Cannot_remove_for_missing_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -432,13 +432,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'recordCompanies' with ID '{companyId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -473,15 +473,15 @@ public async Task Cannot_remove_for_ID_and_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -513,15 +513,15 @@ public async Task Cannot_remove_for_unknown_relationship_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -561,15 +561,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -610,15 +610,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -661,15 +661,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -708,15 +708,15 @@ public async Task Cannot_remove_for_missing_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -756,15 +756,15 @@ public async Task Cannot_remove_for_unknown_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -803,15 +803,15 @@ public async Task Cannot_remove_for_missing_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -852,15 +852,15 @@ public async Task Cannot_remove_for_ID_and_local_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -919,20 +919,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); error1.Title.Should().Be("A related resource does not exist."); error1.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[0]}' in relationship 'tracks' does not exist."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.NotFound); error2.Title.Should().Be("A related resource does not exist."); error2.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[1]}' in relationship 'tracks' does not exist."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -981,15 +981,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1038,7 +1038,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingTrack.Performers[0].Id); }); } @@ -1085,14 +1085,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be removed from."); error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be removed from."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs index c8e093f9ff..38d2d1aac0 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs @@ -68,7 +68,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Performers.Should().BeEmpty(); List performersInDatabase = await dbContext.Performers.ToListAsync(); - performersInDatabase.ShouldHaveCount(2); + performersInDatabase.Should().HaveCount(2); }); } @@ -122,7 +122,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(2); + tracksInDatabase.Should().HaveCount(2); }); } @@ -187,12 +187,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(2); + trackInDatabase.Performers.Should().HaveCount(2); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[0].Id); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[1].Id); List performersInDatabase = await dbContext.Performers.ToListAsync(); - performersInDatabase.ShouldHaveCount(3); + performersInDatabase.Should().HaveCount(3); }); } @@ -257,13 +257,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(2); + playlistInDatabase.Tracks.Should().HaveCount(2); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[1].Id); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(3); + tracksInDatabase.Should().HaveCount(3); }); } @@ -291,15 +291,15 @@ public async Task Cannot_replace_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -330,15 +330,15 @@ public async Task Cannot_replace_for_missing_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -370,15 +370,15 @@ public async Task Cannot_replace_for_unknown_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -409,15 +409,15 @@ public async Task Cannot_replace_for_missing_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -467,13 +467,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'recordCompanies' with ID '{companyId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -525,15 +525,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int16'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -566,15 +566,15 @@ public async Task Cannot_replace_for_ID_and_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -606,15 +606,15 @@ public async Task Cannot_replace_for_unknown_relationship_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -654,15 +654,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -703,15 +703,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -754,15 +754,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -801,15 +801,15 @@ public async Task Cannot_replace_for_missing_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -849,15 +849,15 @@ public async Task Cannot_replace_for_unknown_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -896,15 +896,15 @@ public async Task Cannot_replace_for_missing_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -945,15 +945,15 @@ public async Task Cannot_replace_for_ID_and_local_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1012,20 +1012,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); error1.Title.Should().Be("A related resource does not exist."); error1.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[0]}' in relationship 'tracks' does not exist."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.NotFound); error2.Title.Should().Be("A related resource does not exist."); error2.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[1]}' in relationship 'tracks' does not exist."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -1074,15 +1074,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1130,15 +1130,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1183,14 +1183,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs index e9f99c6171..3d543a15f6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs @@ -68,7 +68,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => lyricInDatabase.Track.Should().BeNull(); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(1); + tracksInDatabase.Should().HaveCount(1); }); } @@ -121,7 +121,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Lyric.Should().BeNull(); List lyricsInDatabase = await dbContext.Lyrics.ToListAsync(); - lyricsInDatabase.ShouldHaveCount(1); + lyricsInDatabase.Should().HaveCount(1); }); } @@ -174,7 +174,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.OwnedBy.Should().BeNull(); List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(1); + companiesInDatabase.Should().HaveCount(1); }); } @@ -227,7 +227,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.Include(lyric => lyric.Track).FirstWithIdAsync(existingLyric.Id); - lyricInDatabase.Track.ShouldNotBeNull(); + lyricInDatabase.Track.Should().NotBeNull(); lyricInDatabase.Track.Id.Should().Be(existingTrack.Id); }); } @@ -281,7 +281,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Lyric).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); }); } @@ -335,7 +335,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); }); } @@ -392,11 +392,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.Include(lyric => lyric.Track).FirstWithIdAsync(existingLyric.Id); - lyricInDatabase.Track.ShouldNotBeNull(); + lyricInDatabase.Track.Should().NotBeNull(); lyricInDatabase.Track.Id.Should().Be(existingTrack.Id); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(2); + tracksInDatabase.Should().HaveCount(2); }); } @@ -452,11 +452,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Lyric).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); List lyricsInDatabase = await dbContext.Lyrics.ToListAsync(); - lyricsInDatabase.ShouldHaveCount(2); + lyricsInDatabase.Should().HaveCount(2); }); } @@ -512,11 +512,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(2); + companiesInDatabase.Should().HaveCount(2); }); } @@ -544,15 +544,15 @@ public async Task Cannot_create_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -583,15 +583,15 @@ public async Task Cannot_create_for_missing_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -623,15 +623,15 @@ public async Task Cannot_create_for_unknown_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -662,15 +662,15 @@ public async Task Cannot_create_for_missing_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -717,13 +717,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'musicTracks' with ID '{trackId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -770,15 +770,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -811,15 +811,15 @@ public async Task Cannot_create_for_ID_and_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -851,15 +851,15 @@ public async Task Cannot_create_for_unknown_relationship_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -899,15 +899,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -955,15 +955,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -999,15 +999,15 @@ public async Task Cannot_create_for_missing_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1044,15 +1044,15 @@ public async Task Cannot_create_for_unknown_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1088,15 +1088,15 @@ public async Task Cannot_create_for_missing_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1134,15 +1134,15 @@ public async Task Cannot_create_for_ID_and_local_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1189,13 +1189,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'lyrics' with ID '{lyricId}' in relationship 'lyric' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -1242,15 +1242,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1295,15 +1295,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1348,14 +1348,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs index 17778fc0a6..31a2b61512 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs @@ -73,7 +73,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Performers.Should().BeEmpty(); List performersInDatabase = await dbContext.Performers.ToListAsync(); - performersInDatabase.ShouldHaveCount(2); + performersInDatabase.Should().HaveCount(2); }); } @@ -132,7 +132,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(2); + tracksInDatabase.Should().HaveCount(2); }); } @@ -202,12 +202,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Performers).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Performers.ShouldHaveCount(2); + trackInDatabase.Performers.Should().HaveCount(2); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[0].Id); trackInDatabase.Performers.Should().ContainSingle(performer => performer.Id == existingPerformers[1].Id); List performersInDatabase = await dbContext.Performers.ToListAsync(); - performersInDatabase.ShouldHaveCount(3); + performersInDatabase.Should().HaveCount(3); }); } @@ -277,13 +277,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Playlist playlistInDatabase = await dbContext.Playlists.Include(playlist => playlist.Tracks).FirstWithIdAsync(existingPlaylist.Id); - playlistInDatabase.Tracks.ShouldHaveCount(2); + playlistInDatabase.Tracks.Should().HaveCount(2); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[0].Id); playlistInDatabase.Tracks.Should().ContainSingle(musicTrack => musicTrack.Id == existingTracks[1].Id); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(3); + tracksInDatabase.Should().HaveCount(3); }); } @@ -329,15 +329,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -383,15 +383,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -439,15 +439,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -491,15 +491,15 @@ public async Task Cannot_replace_for_missing_type_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -544,15 +544,15 @@ public async Task Cannot_replace_for_unknown_type_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -596,15 +596,15 @@ public async Task Cannot_replace_for_missing_ID_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -650,15 +650,15 @@ public async Task Cannot_replace_for_ID_and_local_ID_relationship_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -722,20 +722,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); error1.Title.Should().Be("A related resource does not exist."); error1.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[0]}' in relationship 'tracks' does not exist."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/atomic:operations[0]"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.NotFound); error2.Title.Should().Be("A related resource does not exist."); error2.Detail.Should().Be($"Related resource of type 'musicTracks' with ID '{trackIds[1]}' in relationship 'tracks' does not exist."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/atomic:operations[0]"); } @@ -789,15 +789,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -850,14 +850,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/occursIn"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs index 29a3e10fd5..2e97812c19 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs @@ -89,7 +89,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(elementCount); + tracksInDatabase.Should().HaveCount(elementCount); for (int index = 0; index < elementCount; index++) { @@ -153,7 +153,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(existingTrack.Title); trackInDatabase.Genre.Should().Be(existingTrack.Genre); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingTrack.OwnedBy.Id); }); } @@ -200,15 +200,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown attribute found."); error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -313,15 +313,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'musicTracks'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -431,7 +431,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Genre.Should().Be(newGenre); trackInDatabase.ReleasedAt.Should().Be(existingTrack.ReleasedAt); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingTrack.OwnedBy.Id); }); } @@ -496,7 +496,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Genre.Should().Be(newGenre); trackInDatabase.ReleasedAt.Should().Be(newReleasedAt); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingTrack.OwnedBy.Id); }); } @@ -542,16 +542,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); string isoCode = $"{newIsoCode}{ImplicitlyChangingTextLanguageDefinition.Suffix}"; - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("textLanguages"); - resource.Attributes.ShouldContainKey("isoCode").With(value => value.Should().Be(isoCode)); + resource.Attributes.Should().ContainKey("isoCode").WhoseValue.Should().Be(isoCode); resource.Attributes.Should().NotContainKey("isRightToLeft"); - resource.Relationships.ShouldNotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); }); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -598,11 +598,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { - resource.Relationships.ShouldNotBeEmpty(); + resource.Relationships.Should().NotBeEmpty(); resource.Relationships.Values.Should().OnlyContain(value => value != null && value.Data.Value == null); }); } @@ -631,15 +631,15 @@ public async Task Cannot_update_resource_for_href_element() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'href' element is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -737,15 +737,15 @@ public async Task Cannot_update_resource_for_missing_type_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -786,15 +786,15 @@ public async Task Cannot_update_resource_for_missing_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -837,15 +837,15 @@ public async Task Cannot_update_resource_for_ID_and_local_ID_in_ref() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -871,15 +871,15 @@ public async Task Cannot_update_resource_for_missing_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -906,15 +906,15 @@ public async Task Cannot_update_resource_for_null_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -960,15 +960,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1004,15 +1004,15 @@ public async Task Cannot_update_resource_for_missing_type_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1048,15 +1048,15 @@ public async Task Cannot_update_resource_for_missing_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1094,15 +1094,15 @@ public async Task Cannot_update_resource_for_ID_and_local_ID_in_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1144,15 +1144,15 @@ public async Task Cannot_update_on_resource_type_mismatch_between_ref_and_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1197,15 +1197,15 @@ public async Task Cannot_update_on_resource_ID_mismatch_between_ref_and_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Conflicting 'id' values found."); error.Detail.Should().Be($"Expected '{performerId1}' instead of '{performerId2}'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1247,15 +1247,15 @@ public async Task Cannot_update_on_resource_local_ID_mismatch_between_ref_and_da // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Conflicting 'lid' values found."); error.Detail.Should().Be("Expected 'local-1' instead of 'local-2'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/lid"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1299,15 +1299,15 @@ public async Task Cannot_update_on_mixture_of_ID_and_local_ID_between_ref_and_da // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1351,15 +1351,15 @@ public async Task Cannot_update_on_mixture_of_local_ID_and_ID_between_ref_and_da // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1396,15 +1396,15 @@ public async Task Cannot_update_resource_for_unknown_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1443,13 +1443,13 @@ public async Task Cannot_update_resource_for_unknown_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'performers' with ID '{performerId}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -1492,15 +1492,15 @@ public async Task Cannot_update_resource_for_incompatible_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible 'id' value found."); error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int32'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1543,15 +1543,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute is read-only."); error.Detail.Should().Be("Attribute 'isArchived' on resource type 'playlists' is read-only."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/isArchived"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1594,15 +1594,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Resource ID is read-only."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1645,15 +1645,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible attribute value found."); error.Detail.Should().Be("Failed to convert attribute 'bornAt' with value '123.45' of type 'Number' to type 'DateTimeOffset'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/bornAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1754,13 +1754,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Title.Should().Be(existingTrack.Title); trackInDatabase.Genre.Should().Be(newGenre); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); - trackInDatabase.Performers.ShouldHaveCount(1); + trackInDatabase.Performers.Should().HaveCount(1); trackInDatabase.Performers[0].Id.Should().Be(existingPerformer.Id); }); } @@ -1805,14 +1805,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute value cannot be assigned when updating resource."); error.Detail.Should().Be("The attribute 'createdAt' on resource type 'lyrics' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/createdAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs index 0206ef1e9c..00133e29ea 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs @@ -73,7 +73,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => lyricInDatabase.Track.Should().BeNull(); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(1); + tracksInDatabase.Should().HaveCount(1); }); } @@ -131,7 +131,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.Lyric.Should().BeNull(); List lyricsInDatabase = await dbContext.Lyrics.ToListAsync(); - lyricsInDatabase.ShouldHaveCount(1); + lyricsInDatabase.Should().HaveCount(1); }); } @@ -189,7 +189,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => trackInDatabase.OwnedBy.Should().BeNull(); List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(1); + companiesInDatabase.Should().HaveCount(1); }); } @@ -247,7 +247,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.Include(lyric => lyric.Track).FirstWithIdAsync(existingLyric.Id); - lyricInDatabase.Track.ShouldNotBeNull(); + lyricInDatabase.Track.Should().NotBeNull(); lyricInDatabase.Track.Id.Should().Be(existingTrack.Id); }); } @@ -306,7 +306,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Lyric).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); }); } @@ -365,7 +365,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); }); } @@ -427,11 +427,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Lyric lyricInDatabase = await dbContext.Lyrics.Include(lyric => lyric.Track).FirstWithIdAsync(existingLyric.Id); - lyricInDatabase.Track.ShouldNotBeNull(); + lyricInDatabase.Track.Should().NotBeNull(); lyricInDatabase.Track.Id.Should().Be(existingTrack.Id); List tracksInDatabase = await dbContext.MusicTracks.ToListAsync(); - tracksInDatabase.ShouldHaveCount(2); + tracksInDatabase.Should().HaveCount(2); }); } @@ -492,11 +492,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.Lyric).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.Lyric.ShouldNotBeNull(); + trackInDatabase.Lyric.Should().NotBeNull(); trackInDatabase.Lyric.Id.Should().Be(existingLyric.Id); List lyricsInDatabase = await dbContext.Lyrics.ToListAsync(); - lyricsInDatabase.ShouldHaveCount(2); + lyricsInDatabase.Should().HaveCount(2); }); } @@ -557,11 +557,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { MusicTrack trackInDatabase = await dbContext.MusicTracks.Include(musicTrack => musicTrack.OwnedBy).FirstWithIdAsync(existingTrack.Id); - trackInDatabase.OwnedBy.ShouldNotBeNull(); + trackInDatabase.OwnedBy.Should().NotBeNull(); trackInDatabase.OwnedBy.Id.Should().Be(existingCompany.Id); List companiesInDatabase = await dbContext.RecordCompanies.ToListAsync(); - companiesInDatabase.ShouldHaveCount(2); + companiesInDatabase.Should().HaveCount(2); }); } @@ -605,15 +605,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -658,15 +658,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -719,15 +719,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -768,15 +768,15 @@ public async Task Cannot_create_for_missing_type_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/track/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -818,15 +818,15 @@ public async Task Cannot_create_for_unknown_type_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -867,15 +867,15 @@ public async Task Cannot_create_for_missing_ID_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' or 'lid' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -918,15 +918,15 @@ public async Task Cannot_create_for_ID_and_local_ID_in_relationship_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' and 'lid' element are mutually exclusive."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -978,13 +978,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); error.Title.Should().Be("A related resource does not exist."); error.Detail.Should().Be($"Related resource of type 'lyrics' with ID '{lyricId}' in relationship 'lyric' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); error.Meta.Should().NotContainKey("requestBody"); } @@ -1036,15 +1036,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1094,14 +1094,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/language"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeOperationsTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeOperationsTests.cs index 330ea277df..d8834ce7fa 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeOperationsTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeOperationsTests.cs @@ -86,13 +86,13 @@ public async Task Cannot_create_resources_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -137,13 +137,13 @@ public async Task Cannot_create_resource_with_read_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:genres."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -195,13 +195,13 @@ public async Task Cannot_update_resources_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -253,13 +253,13 @@ public async Task Cannot_update_resource_with_relationships_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -300,13 +300,13 @@ public async Task Cannot_delete_resources_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:genres."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -340,13 +340,13 @@ public async Task Cannot_update_ToOne_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -380,13 +380,13 @@ public async Task Cannot_update_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -420,13 +420,13 @@ public async Task Cannot_add_to_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -460,13 +460,13 @@ public async Task Cannot_remove_from_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeReadTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeReadTests.cs index c1004c3e21..91530044df 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeReadTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeReadTests.cs @@ -34,13 +34,13 @@ public async Task Cannot_get_primary_resources_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -58,13 +58,13 @@ public async Task Cannot_get_primary_resources_with_incorrect_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -92,11 +92,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("movies"); responseDocument.Data.ManyValue[0].Id.Should().Be(movie.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldNotBeEmpty(); - responseDocument.Data.ManyValue[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Data.ManyValue[0].Attributes.Should().NotBeEmpty(); + responseDocument.Data.ManyValue[0].Relationships.Should().NotBeEmpty(); } [Fact] @@ -122,11 +122,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("genres"); responseDocument.Data.ManyValue[0].Id.Should().Be(genre.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldNotBeEmpty(); - responseDocument.Data.ManyValue[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Data.ManyValue[0].Attributes.Should().NotBeEmpty(); + responseDocument.Data.ManyValue[0].Relationships.Should().NotBeEmpty(); } [Fact] @@ -152,11 +152,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("actors"); responseDocument.Data.ManyValue[0].Id.Should().Be(actor.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldNotBeEmpty(); - responseDocument.Data.ManyValue[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Data.ManyValue[0].Attributes.Should().NotBeEmpty(); + responseDocument.Data.ManyValue[0].Relationships.Should().NotBeEmpty(); } [Fact] @@ -171,13 +171,13 @@ public async Task Cannot_get_primary_resource_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:actors."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -193,13 +193,13 @@ public async Task Cannot_get_secondary_resource_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -215,13 +215,13 @@ public async Task Cannot_get_secondary_resources_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -237,13 +237,13 @@ public async Task Cannot_get_ToOne_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -259,13 +259,13 @@ public async Task Cannot_get_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -283,13 +283,13 @@ public async Task Cannot_include_with_insufficient_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:actors read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -307,13 +307,13 @@ public async Task Cannot_filter_with_insufficient_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:actors read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -331,13 +331,13 @@ public async Task Cannot_sort_with_insufficient_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: read:actors read:genres read:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeWriteTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeWriteTests.cs index 1db9a7cf36..ef1e7d5aca 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeWriteTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Authorization/Scopes/ScopeWriteTests.cs @@ -48,13 +48,13 @@ public async Task Cannot_create_resource_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -108,13 +108,13 @@ public async Task Cannot_create_resource_with_relationships_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -171,13 +171,13 @@ public async Task Cannot_create_resource_with_relationships_with_read_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -208,13 +208,13 @@ public async Task Cannot_update_resource_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -267,13 +267,13 @@ public async Task Cannot_update_resource_with_relationships_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -289,13 +289,13 @@ public async Task Cannot_delete_resource_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -320,13 +320,13 @@ public async Task Cannot_update_ToOne_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:genres write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -354,13 +354,13 @@ public async Task Cannot_update_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -388,13 +388,13 @@ public async Task Cannot_add_to_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } @@ -422,13 +422,13 @@ public async Task Cannot_remove_from_ToMany_relationship_without_scopes() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Unauthorized); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Unauthorized); error.Title.Should().Be("Insufficient permissions to perform this request."); error.Detail.Should().Be("Performing this request requires the following scopes: write:actors write:movies."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be(ScopeHeaderName); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobTests.cs index faac9f2b1f..3716c56214 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Blobs/BlobTests.cs @@ -42,12 +42,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("imageContainers"); responseDocument.Data.SingleValue.Id.Should().Be(container.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("fileName").With(value => value.Should().Be(container.FileName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("data").As().With(value => value.Should().Equal(container.Data)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("thumbnail").As().With(value => value.Should().Equal(container.Thumbnail)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("fileName").WhoseValue.Should().Be(container.FileName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("data").WhoseValue.As().Should().Equal(container.Data); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("thumbnail").WhoseValue.As().Should().Equal(container.Thumbnail); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -79,14 +79,14 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("imageContainers"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("fileName").With(value => value.Should().Be(newContainer.FileName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("data").As().With(value => value.Should().Equal(newContainer.Data)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("thumbnail").As().With(value => value.Should().Equal(newContainer.Thumbnail)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("fileName").WhoseValue.Should().Be(newContainer.FileName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("data").WhoseValue.As().Should().Equal(newContainer.Data); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("thumbnail").WhoseValue.As().Should().Equal(newContainer.Thumbnail); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - long newContainerId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newContainerId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -135,12 +135,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("imageContainers"); responseDocument.Data.SingleValue.Id.Should().Be(existingContainer.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("fileName").With(value => value.Should().Be(existingContainer.FileName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("data").As().With(value => value.Should().Equal(newData)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("thumbnail").As().With(value => value.Should().Equal(newThumbnail)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("fileName").WhoseValue.Should().Be(existingContainer.FileName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("data").WhoseValue.As().With(value => value.Should().Equal(newData)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("thumbnail").WhoseValue.As().With(value => value.Should().Equal(newThumbnail)); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -186,11 +186,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("imageContainers"); responseDocument.Data.SingleValue.Id.Should().Be(existingContainer.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("fileName").With(value => value.Should().Be(existingContainer.FileName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("data").As().With(value => value.Should().BeEmpty()); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("fileName").WhoseValue.Should().Be(existingContainer.FileName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("data").WhoseValue.As().With(value => value.Should().BeEmpty()); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -235,11 +235,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("imageContainers"); responseDocument.Data.SingleValue.Id.Should().Be(existingContainer.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("fileName").With(value => value.Should().Be(existingContainer.FileName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("thumbnail").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("fileName").WhoseValue.Should().Be(existingContainer.FileName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("thumbnail").WhoseValue.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs index 01e8b18fb7..3ea92e7c17 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CompositeKeys/CompositeKeyTests.cs @@ -49,7 +49,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(car.StringId); } @@ -74,7 +74,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(car.StringId); } @@ -99,7 +99,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(car.StringId); } @@ -124,7 +124,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(car.StringId); } @@ -181,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Car? carInDatabase = await dbContext.Cars.FirstOrDefaultAsync(car => car.RegionId == newCar.RegionId && car.LicensePlate == newCar.LicensePlate); - carInDatabase.ShouldNotBeNull(); + carInDatabase.Should().NotBeNull(); carInDatabase.Id.Should().Be($"{newCar.RegionId}:{newCar.LicensePlate}"); }); } @@ -234,7 +234,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Engine engineInDatabase = await dbContext.Engines.Include(engine => engine.Car).FirstWithIdAsync(existingEngine.Id); - engineInDatabase.Car.ShouldNotBeNull(); + engineInDatabase.Car.Should().NotBeNull(); engineInDatabase.Car.Id.Should().Be(existingCar.StringId); }); } @@ -327,7 +327,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Dealership dealershipInDatabase = await dbContext.Dealerships.Include(dealership => dealership.Inventory).FirstWithIdAsync(existingDealership.Id); - dealershipInDatabase.Inventory.ShouldHaveCount(1); + dealershipInDatabase.Inventory.Should().HaveCount(1); dealershipInDatabase.Inventory.Should().ContainSingle(car => car.Id == existingDealership.Inventory.ElementAt(1).Id); }); } @@ -372,7 +372,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Dealership dealershipInDatabase = await dbContext.Dealerships.Include(dealership => dealership.Inventory).FirstWithIdAsync(existingDealership.Id); - dealershipInDatabase.Inventory.ShouldHaveCount(1); + dealershipInDatabase.Inventory.Should().HaveCount(1); dealershipInDatabase.Inventory.Should().ContainSingle(car => car.Id == existingCar.Id); }); } @@ -424,7 +424,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Dealership dealershipInDatabase = await dbContext.Dealerships.Include(dealership => dealership.Inventory).FirstWithIdAsync(existingDealership.Id); - dealershipInDatabase.Inventory.ShouldHaveCount(2); + dealershipInDatabase.Inventory.Should().HaveCount(2); dealershipInDatabase.Inventory.Should().ContainSingle(car => car.Id == existingCar.Id); dealershipInDatabase.Inventory.Should().ContainSingle(car => car.Id == existingDealership.Inventory.ElementAt(0).Id); }); @@ -465,7 +465,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -545,11 +545,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Dealership dealershipInDatabase = await dbContext.Dealerships.Include(dealership => dealership.SoldCars).FirstWithIdAsync(existingDealership.Id); - dealershipInDatabase.SoldCars.ShouldHaveCount(1); + dealershipInDatabase.SoldCars.Should().HaveCount(1); dealershipInDatabase.SoldCars.Single().Id.Should().Be(existingDealership.SoldCars.ElementAt(0).Id); List carsInDatabase = await dbContext.Cars.ToListAsync(); - carsInDatabase.ShouldHaveCount(2); + carsInDatabase.Should().HaveCount(2); }); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/AcceptHeaderTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/AcceptHeaderTests.cs index 6927e811c9..d7b1616501 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/AcceptHeaderTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/AcceptHeaderTests.cs @@ -38,7 +38,7 @@ public async Task Permits_global_wildcard_in_Accept_headers() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -60,7 +60,7 @@ public async Task Permits_application_wildcard_in_Accept_headers() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -85,7 +85,7 @@ public async Task Permits_JsonApi_without_parameters_in_Accept_headers() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -131,7 +131,7 @@ public async Task Prefers_JsonApi_with_AtomicOperations_extension_in_Accept_head // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.AtomicOperations.ToString()); } @@ -177,7 +177,7 @@ public async Task Prefers_JsonApi_with_relaxed_AtomicOperations_extension_in_Acc // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.RelaxedAtomicOperations.ToString()); } @@ -202,13 +202,13 @@ public async Task Denies_JsonApi_with_parameters_in_Accept_headers() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotAcceptable); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotAcceptable); error.Title.Should().Be("The specified Accept header value does not contain any supported media types."); error.Detail.Should().Be($"Include '{JsonApiMediaType.Default}' in the Accept header values."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Accept"); } @@ -249,13 +249,13 @@ public async Task Denies_no_Accept_headers_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotAcceptable); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotAcceptable); error.Title.Should().Be("The specified Accept header value does not contain any supported media types."); error.Detail.Should().Be($"Include '{JsonApiMediaType.AtomicOperations}' or '{JsonApiMediaType.RelaxedAtomicOperations}' in the Accept header values."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Accept"); } @@ -295,13 +295,13 @@ public async Task Denies_JsonApi_in_Accept_headers_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotAcceptable); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotAcceptable); error.Title.Should().Be("The specified Accept header value does not contain any supported media types."); error.Detail.Should().Be($"Include '{JsonApiMediaType.AtomicOperations}' or '{JsonApiMediaType.RelaxedAtomicOperations}' in the Accept header values."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Accept"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs index 19948c0092..5627265ea6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/ContentTypeHeaderTests.cs @@ -32,7 +32,7 @@ public async Task Returns_JsonApi_ContentType_header() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -67,7 +67,7 @@ public async Task Returns_JsonApi_ContentType_header_with_AtomicOperations_exten // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.AtomicOperations.ToString()); } @@ -106,7 +106,7 @@ public async Task Returns_JsonApi_ContentType_header_with_relaxed_AtomicOperatio // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.RelaxedAtomicOperations.ToString()); } @@ -135,16 +135,16 @@ public async Task Denies_unknown_ContentType_header() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of 'text/html' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -180,10 +180,10 @@ public async Task Denies_unknown_ContentType_header_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Use '{JsonApiMediaType.AtomicOperations}' or '{JsonApiMediaType.RelaxedAtomicOperations}' instead of 'text/html' for the Content-Type header value."; @@ -192,7 +192,7 @@ public async Task Denies_unknown_ContentType_header_at_operations_endpoint() error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -221,7 +221,7 @@ public async Task Permits_JsonApi_ContentType_header() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -250,7 +250,7 @@ public async Task Permits_JsonApi_ContentType_header_in_upper_case() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -285,7 +285,7 @@ public async Task Permits_JsonApi_ContentType_header_with_AtomicOperations_exten // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.AtomicOperations.ToString()); } @@ -321,10 +321,10 @@ public async Task Denies_JsonApi_ContentType_header_with_AtomicOperations_extens // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Use '{JsonApiMediaType.AtomicOperations}' or '{JsonApiMediaType.RelaxedAtomicOperations}' instead of '{contentType}' for the Content-Type header value."; @@ -333,7 +333,7 @@ public async Task Denies_JsonApi_ContentType_header_with_AtomicOperations_extens error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -372,7 +372,7 @@ public async Task Permits_JsonApi_ContentType_header_with_relaxed_AtomicOperatio // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.RelaxedAtomicOperations.ToString()); } @@ -401,16 +401,16 @@ public async Task Denies_JsonApi_ContentType_header_with_unknown_extension() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -439,16 +439,16 @@ public async Task Denies_JsonApi_ContentType_header_with_AtomicOperations_extens // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -477,16 +477,16 @@ public async Task Denies_JsonApi_ContentType_header_with_relaxed_AtomicOperation // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -515,16 +515,16 @@ public async Task Denies_JsonApi_ContentType_header_with_profile() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -553,16 +553,16 @@ public async Task Denies_JsonApi_ContentType_header_with_CharSet() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -591,16 +591,16 @@ public async Task Denies_JsonApi_ContentType_header_with_unknown_parameter() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be($"Use '{JsonApiMediaType.Default}' instead of '{contentType}' for the Content-Type header value."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -636,10 +636,10 @@ public async Task Denies_JsonApi_ContentType_header_at_operations_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Use '{JsonApiMediaType.AtomicOperations}' or '{JsonApiMediaType.RelaxedAtomicOperations}' instead of '{contentType}' for the Content-Type header value."; @@ -648,7 +648,7 @@ public async Task Denies_JsonApi_ContentType_header_at_operations_endpoint() error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsAcceptHeaderTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsAcceptHeaderTests.cs index b5f6367b73..d1c859aaea 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsAcceptHeaderTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsAcceptHeaderTests.cs @@ -54,7 +54,7 @@ public async Task Permits_JsonApi_without_parameters_in_Accept_headers() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -78,7 +78,7 @@ public async Task Prefers_first_match_from_GetPossibleMediaTypes_with_largest_nu // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(ServerTimeMediaTypes.ServerTime.ToString()); } @@ -101,7 +101,7 @@ public async Task Prefers_quality_factor_over_largest_number_of_extensions() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -141,7 +141,7 @@ public async Task Denies_extensions_mismatch_between_ContentType_and_Accept_head // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotAcceptable); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Include '{JsonApiMediaType.AtomicOperations}' or '{ServerTimeMediaTypes.AtomicOperationsWithServerTime}' or " + $"'{JsonApiMediaType.RelaxedAtomicOperations}' or '{ServerTimeMediaTypes.RelaxedAtomicOperationsWithRelaxedServerTime}' in the Accept header values."; @@ -150,7 +150,7 @@ public async Task Denies_extensions_mismatch_between_ContentType_and_Accept_head error.StatusCode.Should().Be(HttpStatusCode.NotAcceptable); error.Title.Should().Be("The specified Accept header value does not contain any supported media types."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Accept"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsContentTypeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsContentTypeTests.cs index 3a991dc13d..261f7b5149 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsContentTypeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ContentNegotiation/CustomExtensions/CustomExtensionsContentTypeTests.cs @@ -74,7 +74,7 @@ public async Task Permits_JsonApi_ContentType_header() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); } @@ -111,11 +111,11 @@ public async Task Permits_JsonApi_ContentType_header_with_ServerTime_extension() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(ServerTimeMediaTypes.ServerTime.ToString()); - responseDocument.Meta.ShouldContainKey("localServerTime").With(time => - time.ShouldNotBeNull().ToString().Should().Be("2025-01-01T06:53:40.0000000+09:00")); + responseDocument.Meta.Should().ContainKey("localServerTime").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should() + .Be("2025-01-01T06:53:40.0000000+09:00"); } [Fact] @@ -147,10 +147,11 @@ public async Task Permits_JsonApi_ContentType_header_with_relaxed_ServerTime_ext // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(ServerTimeMediaTypes.RelaxedServerTime.ToString()); - responseDocument.Meta.ShouldContainKey("utcServerTime").With(time => time.ShouldNotBeNull().ToString().Should().Be("2024-12-31T21:53:40.0000000Z")); + responseDocument.Meta.Should().ContainKey("utcServerTime").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should() + .Be("2024-12-31T21:53:40.0000000Z"); } [Fact] @@ -189,10 +190,11 @@ public async Task Permits_JsonApi_ContentType_header_with_AtomicOperations_and_S // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(ServerTimeMediaTypes.AtomicOperationsWithServerTime.ToString()); - responseDocument.Meta.ShouldContainKey("utcServerTime").With(time => time.ShouldNotBeNull().ToString().Should().Be("2024-12-31T21:53:40.0000000Z")); + responseDocument.Meta.Should().ContainKey("utcServerTime").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should() + .Be("2024-12-31T21:53:40.0000000Z"); } [Fact] @@ -236,10 +238,10 @@ public async Task Permits_JsonApi_ContentType_header_with_relaxed_AtomicOperatio // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(ServerTimeMediaTypes.RelaxedAtomicOperationsWithRelaxedServerTime.ToString()); - responseDocument.Meta.ShouldContainKey("localServerTime"); + responseDocument.Meta.Should().ContainKey("localServerTime"); } [Fact] @@ -267,10 +269,10 @@ public async Task Denies_JsonApi_ContentType_header_with_AtomicOperations_extens // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Use '{JsonApiMediaType.Default}' or '{ServerTimeMediaTypes.ServerTime}' or " + $"'{ServerTimeMediaTypes.RelaxedServerTime}' instead of '{contentType}' for the Content-Type header value."; @@ -279,7 +281,7 @@ public async Task Denies_JsonApi_ContentType_header_with_AtomicOperations_extens error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } @@ -315,10 +317,10 @@ public async Task Denies_JsonApi_ContentType_header_with_relaxed_ServerTime_at_o // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnsupportedMediaType); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string detail = $"Use '{JsonApiMediaType.AtomicOperations}' or '{ServerTimeMediaTypes.AtomicOperationsWithServerTime}' or " + $"'{JsonApiMediaType.RelaxedAtomicOperations}' or '{ServerTimeMediaTypes.RelaxedAtomicOperationsWithRelaxedServerTime}' " + @@ -328,7 +330,7 @@ public async Task Denies_JsonApi_ContentType_header_with_relaxed_ServerTime_at_o error.StatusCode.Should().Be(HttpStatusCode.UnsupportedMediaType); error.Title.Should().Be("The specified Content-Type header value is not supported."); error.Detail.Should().Be(detail); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("Content-Type"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ControllerActionResults/ActionResultTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ControllerActionResults/ActionResultTests.cs index b11c31623c..fe047449f1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ControllerActionResults/ActionResultTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ControllerActionResults/ActionResultTests.cs @@ -37,7 +37,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(toothbrush.StringId); } @@ -53,7 +53,7 @@ public async Task Converts_empty_ActionResult_to_error_collection() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -73,7 +73,7 @@ public async Task Converts_ActionResult_with_error_object_to_error_collection() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -93,7 +93,7 @@ public async Task Cannot_convert_ActionResult_with_string_parameter_to_error_col // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.InternalServerError); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.InternalServerError); @@ -113,7 +113,7 @@ public async Task Converts_ObjectResult_with_error_object_to_error_collection() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadGateway); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadGateway); @@ -133,7 +133,7 @@ public async Task Converts_ObjectResult_with_error_objects_to_error_collection() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(3); + responseDocument.Errors.Should().HaveCount(3); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.PreconditionFailed); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeLogTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeLogTests.cs index 69c71e5d82..132fa446b1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeLogTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeLogTests.cs @@ -35,7 +35,7 @@ public void Logs_warning_at_startup_when_ApiControllerAttribute_found() // Assert IReadOnlyList logLines = _loggerProvider.GetLines(); - logLines.ShouldHaveCount(1); + logLines.Should().HaveCount(1); logLines[0].Should().Be( $"[WARNING] Found JSON:API controller '{typeof(CiviliansController)}' with [ApiController]. Please remove this attribute for optimal JSON:API compliance."); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs index a27ef77329..731401137b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/ApiControllerAttributeTests.cs @@ -29,10 +29,10 @@ public async Task ApiController_attribute_transforms_NotFound_action_result_with // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; - error.Links.ShouldNotBeNull(); + error.Links.Should().NotBeNull(); error.Links.About.Should().StartWith("https://tools.ietf.org/html/rfc"); } @@ -61,11 +61,11 @@ public async Task ProblemDetails_from_invalid_ModelState_is_translated_into_erro // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.BadRequest); - error1.Links.ShouldNotBeNull(); + error1.Links.Should().NotBeNull(); error1.Links.About.Should().StartWith("https://tools.ietf.org/html/rfc"); error1.Title.Should().Be("One or more validation errors occurred."); error1.Detail.Should().Be("The Name field is required."); @@ -73,7 +73,7 @@ public async Task ProblemDetails_from_invalid_ModelState_is_translated_into_erro ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.BadRequest); - error2.Links.ShouldNotBeNull(); + error2.Links.Should().NotBeNull(); error2.Links.About.Should().StartWith("https://tools.ietf.org/html/rfc"); error2.Title.Should().Be("One or more validation errors occurred."); error2.Detail.Should().Be("The field YearOfBirth must be between 1900 and 2050."); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs index 92ba48b2f9..eb74e50fb4 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/CustomRoutes/CustomRouteTests.cs @@ -42,24 +42,24 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("towns"); responseDocument.Data.SingleValue.Id.Should().Be(town.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(town.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("latitude").With(value => value.Should().Be(town.Latitude)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("longitude").With(value => value.Should().Be(town.Longitude)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(town.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("latitude").WhoseValue.Should().Be(town.Latitude); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("longitude").WhoseValue.Should().Be(town.Longitude); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("civilians").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("civilians").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{HostPrefix}{route}/relationships/civilians"); value.Links.Related.Should().Be($"{HostPrefix}{route}/civilians"); }); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{HostPrefix}{route}"); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); } @@ -84,9 +84,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(5); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Type == "towns"); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Attributes.ShouldNotBeNull().Count > 0); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Relationships.ShouldNotBeNull().Count > 0); + responseDocument.Data.ManyValue.Should().HaveCount(5); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Type == "towns"); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Attributes != null && resource.Attributes.Count > 0); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships != null && resource.Relationships.Count > 0); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs index 353417d1ba..8b64dfcbbf 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/EagerLoading/EagerLoadingTests.cs @@ -51,12 +51,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(building.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("number").With(value => value.Should().Be(building.Number)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("windowCount").With(value => value.Should().Be(4)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("primaryDoorColor").With(value => value.Should().Be(building.PrimaryDoor.Color)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("secondaryDoorColor").With(value => value.Should().Be(building.SecondaryDoor.Color)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("number").WhoseValue.Should().Be(building.Number); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("windowCount").WhoseValue.Should().Be(4); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("primaryDoorColor").WhoseValue.Should().Be(building.PrimaryDoor.Color); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("secondaryDoorColor").WhoseValue.Should().Be(building.SecondaryDoor.Color); } [Fact] @@ -87,12 +87,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(street.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(street.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("buildingCount").With(value => value.Should().Be(2)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("doorTotalCount").With(value => value.Should().Be(3)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("windowTotalCount").With(value => value.Should().Be(5)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(street.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("buildingCount").WhoseValue.Should().Be(2); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("doorTotalCount").WhoseValue.Should().Be(3); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("windowTotalCount").WhoseValue.Should().Be(5); } [Fact] @@ -118,10 +118,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(street.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("windowTotalCount").With(value => value.Should().Be(3)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("windowTotalCount").WhoseValue.Should().Be(3); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -150,21 +150,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(state.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(state.Name)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(state.Name); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("cities"); responseDocument.Included[0].Id.Should().Be(state.Cities[0].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(state.Cities[0].Name)); + responseDocument.Included[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(state.Cities[0].Name); responseDocument.Included[1].Type.Should().Be("streets"); responseDocument.Included[1].Id.Should().Be(state.Cities[0].Streets[0].StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("buildingCount").With(value => value.Should().Be(1)); - responseDocument.Included[1].Attributes.ShouldContainKey("doorTotalCount").With(value => value.Should().Be(1)); - responseDocument.Included[1].Attributes.ShouldContainKey("windowTotalCount").With(value => value.Should().Be(3)); + responseDocument.Included[1].Attributes.Should().ContainKey("buildingCount").WhoseValue.Should().Be(1); + responseDocument.Included[1].Attributes.Should().ContainKey("doorTotalCount").WhoseValue.Should().Be(1); + responseDocument.Included[1].Attributes.Should().ContainKey("windowTotalCount").WhoseValue.Should().Be(3); } [Fact] @@ -193,18 +193,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(state.Cities[0].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(state.Cities[0].Name)); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(state.Cities[0].Name); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("streets"); responseDocument.Included[0].Id.Should().Be(state.Cities[0].Streets[0].StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(2); - responseDocument.Included[0].Attributes.ShouldContainKey("doorTotalCount").With(value => value.Should().Be(2)); - responseDocument.Included[0].Attributes.ShouldContainKey("windowTotalCount").With(value => value.Should().Be(1)); + responseDocument.Included[0].Attributes.Should().HaveCount(2); + responseDocument.Included[0].Attributes.Should().ContainKey("doorTotalCount").WhoseValue.Should().Be(2); + responseDocument.Included[0].Attributes.Should().ContainKey("windowTotalCount").WhoseValue.Should().Be(1); responseDocument.Included[0].Relationships.Should().BeNull(); } @@ -234,13 +234,13 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("number").With(value => value.Should().Be(newBuilding.Number)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("windowCount").With(value => value.Should().Be(0)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("primaryDoorColor").With(value => value.Should().Be("(unspecified)")); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("secondaryDoorColor").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("number").WhoseValue.Should().Be(newBuilding.Number); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("windowCount").WhoseValue.Should().Be(0); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("primaryDoorColor").WhoseValue.Should().Be("(unspecified)"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("secondaryDoorColor").WhoseValue.Should().BeNull(); - int newBuildingId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newBuildingId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -256,9 +256,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - buildingInDatabase.ShouldNotBeNull(); + buildingInDatabase.Should().NotBeNull(); buildingInDatabase.Number.Should().Be(newBuilding.Number); - buildingInDatabase.PrimaryDoor.ShouldNotBeNull(); + buildingInDatabase.PrimaryDoor.Should().NotBeNull(); buildingInDatabase.PrimaryDoor.Color.Should().Be("(unspecified)"); buildingInDatabase.SecondaryDoor.Should().BeNull(); buildingInDatabase.Windows.Should().BeEmpty(); @@ -321,12 +321,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - buildingInDatabase.ShouldNotBeNull(); + buildingInDatabase.Should().NotBeNull(); buildingInDatabase.Number.Should().Be(newBuildingNumber); - buildingInDatabase.PrimaryDoor.ShouldNotBeNull(); + buildingInDatabase.PrimaryDoor.Should().NotBeNull(); buildingInDatabase.PrimaryDoor.Color.Should().Be(newPrimaryDoorColor); - buildingInDatabase.SecondaryDoor.ShouldNotBeNull(); - buildingInDatabase.Windows.ShouldHaveCount(2); + buildingInDatabase.SecondaryDoor.Should().NotBeNull(); + buildingInDatabase.Windows.Should().HaveCount(2); }); } @@ -364,13 +364,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The PrimaryDoorColor field is required."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/primaryDoorColor"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs index 66096c667e..8a635c734f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs @@ -64,14 +64,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Gone); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Gone); error.Title.Should().Be("The requested article is no longer available."); error.Detail.Should().Be("Article with code 'X123' is no longer available."); - error.Meta.ShouldContainKey("support").With(value => + error.Meta.Should().ContainKey("support").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be("Please contact us for info about similar articles at company@email.com."); @@ -80,7 +80,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().BeNull(); IReadOnlyList logMessages = loggerProvider.GetMessages(); - logMessages.ShouldHaveCount(1); + logMessages.Should().HaveCount(1); logMessages[0].LogLevel.Should().Be(LogLevel.Warning); logMessages[0].Text.Should().Contain("Article with code 'X123' is no longer available."); @@ -103,25 +103,25 @@ public async Task Logs_and_produces_error_response_on_deserialization_failure() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be("Resource type '' does not exist."); - error.Meta.ShouldContainKey("requestBody").With(value => + error.Meta.Should().ContainKey("requestBody").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetString().Should().Be(requestBody); }); - error.Meta.ShouldContainKey("stackTrace").With(value => + error.Meta.Should().ContainKey("stackTrace").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); - stackTraceLines.ShouldNotBeEmpty(); + stackTraceLines.Should().NotBeEmpty(); }); IReadOnlyList logMessages = loggerProvider.GetMessages(); @@ -151,14 +151,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.InternalServerError); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.InternalServerError); error.Title.Should().Be("An unhandled error occurred while processing this request."); error.Detail.Should().Be("Exception has been thrown by the target of an invocation."); - error.Meta.ShouldContainKey("stackTrace").With(value => + error.Meta.Should().ContainKey("stackTrace").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); @@ -169,7 +169,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Meta.Should().BeNull(); IReadOnlyList logMessages = loggerProvider.GetMessages(); - logMessages.ShouldHaveCount(1); + logMessages.Should().HaveCount(1); logMessages[0].LogLevel.Should().Be(LogLevel.Error); logMessages[0].Text.Should().Contain("Exception has been thrown by the target of an invocation."); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingTests.cs index 397da59595..d3ab6edd78 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/HostingInIIS/HostingTests.cs @@ -43,7 +43,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -51,19 +51,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Prev.Should().BeNull(); responseDocument.Links.Next.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string galleryLink = $"{HostPrefix}/iis-application-virtual-directory/public-api/artGalleries/{gallery.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(galleryLink); - resource.Relationships.ShouldContainKey("paintings").With(value => + resource.Relationships.Should().ContainKey("paintings").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{galleryLink}/relationships/paintings"); value.Links.Related.Should().Be($"{galleryLink}/paintings"); }); @@ -71,17 +71,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string paintingLink = $"{HostPrefix}/iis-application-virtual-directory/custom/path/to/paintings-of-the-world/{gallery.Paintings.ElementAt(0).StringId}"; - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(paintingLink); - resource.Relationships.ShouldContainKey("exposedAt").With(value => + resource.Relationships.Should().ContainKey("exposedAt").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{paintingLink}/relationships/exposedAt"); value.Links.Related.Should().Be($"{paintingLink}/exposedAt"); }); @@ -110,7 +110,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -118,37 +118,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Prev.Should().BeNull(); responseDocument.Links.Next.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string paintingLink = $"{HostPrefix}/iis-application-virtual-directory/custom/path/to/paintings-of-the-world/{painting.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(paintingLink); - resource.Relationships.ShouldContainKey("exposedAt").With(value => + resource.Relationships.Should().ContainKey("exposedAt").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{paintingLink}/relationships/exposedAt"); value.Links.Related.Should().Be($"{paintingLink}/exposedAt"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string galleryLink = $"{HostPrefix}/iis-application-virtual-directory/public-api/artGalleries/{painting.ExposedAt.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(galleryLink); - resource.Relationships.ShouldContainKey("paintings").With(value => + resource.Relationships.Should().ContainKey("paintings").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{galleryLink}/relationships/paintings"); value.Links.Related.Should().Be($"{galleryLink}/paintings"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs index 02b0001268..e5383f3f7d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs @@ -41,7 +41,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[1].StringId); } @@ -58,13 +58,13 @@ public async Task Cannot_filter_equality_for_invalid_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"The value 'not-a-hex-value' is not a valid hexadecimal value. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -90,7 +90,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[1].StringId); } @@ -106,7 +106,7 @@ public async Task Cannot_get_primary_resource_for_invalid_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -135,7 +135,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(card.StringId); } @@ -160,7 +160,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(account.Cards[0].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(account.Cards[1].StringId); } @@ -186,12 +186,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(account.StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(account.Cards[0].StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); + responseDocument.Included[0].Attributes.Should().HaveCount(1); responseDocument.Included[0].Relationships.Should().BeNull(); } @@ -216,7 +216,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(account.Cards[0].StringId); } @@ -265,9 +265,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("ownerName").With(value => value.Should().Be(newCard.OwnerName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("pinCode").With(value => value.Should().Be(newCard.PinCode)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("ownerName").WhoseValue.Should().Be(newCard.OwnerName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("pinCode").WhoseValue.Should().Be(newCard.PinCode); var codec = new HexadecimalCodec(); int newCardId = codec.Decode(responseDocument.Data.SingleValue.Id); @@ -279,7 +279,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); cardInDatabase.PinCode.Should().Be(newCard.PinCode); - cardInDatabase.Account.ShouldNotBeNull(); + cardInDatabase.Account.Should().NotBeNull(); cardInDatabase.Account.Id.Should().Be(existingAccount.Id); cardInDatabase.Account.StringId.Should().Be(existingAccount.StringId); }); @@ -346,7 +346,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => accountInDatabase.Iban.Should().Be(newIban); - accountInDatabase.Cards.ShouldHaveCount(1); + accountInDatabase.Cards.Should().HaveCount(1); accountInDatabase.Cards[0].Id.Should().Be(existingCard.Id); accountInDatabase.Cards[0].StringId.Should().Be(existingCard.StringId); }); @@ -394,7 +394,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); - accountInDatabase.Cards.ShouldHaveCount(2); + accountInDatabase.Cards.Should().HaveCount(2); }); } @@ -437,7 +437,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); - accountInDatabase.Cards.ShouldHaveCount(1); + accountInDatabase.Cards.Should().HaveCount(1); }); } @@ -487,7 +487,7 @@ public async Task Cannot_delete_unknown_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs index 68e7207e4a..7cedc98f5e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/ModelStateValidationTests.cs @@ -43,13 +43,13 @@ public async Task Cannot_create_resource_with_omitted_required_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The Name field is required."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/directoryName"); } @@ -78,13 +78,13 @@ public async Task Cannot_create_resource_with_null_for_required_attribute_value( // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The Name field is required."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/directoryName"); } @@ -113,13 +113,13 @@ public async Task Cannot_create_resource_with_invalid_attribute_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be(@"The field Name must match the regular expression '^[\w\s]+$'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/directoryName"); } @@ -153,20 +153,20 @@ public async Task Cannot_create_resource_with_invalid_DateOnly_TimeOnly_attribut // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().StartWith("The field CreatedAt must be between "); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/attributes/createdAt"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().StartWith("The field CreatedOn must be between "); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/attributes/createdOn"); } @@ -197,9 +197,9 @@ public async Task Can_create_resource_with_valid_attribute_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("directoryName").With(value => value.Should().Be(newDirectory.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isCaseSensitive").With(value => value.Should().Be(newDirectory.IsCaseSensitive)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("directoryName").WhoseValue.Should().Be(newDirectory.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isCaseSensitive").WhoseValue.Should().Be(newDirectory.IsCaseSensitive); } [Fact] @@ -225,20 +225,20 @@ public async Task Cannot_create_resource_with_multiple_violations() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Name field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/attributes/directoryName"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The IsCaseSensitive field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/attributes/isCaseSensitive"); } @@ -265,7 +265,7 @@ public async Task Does_not_exceed_MaxModelValidationErrors() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(3); + responseDocument.Errors.Should().HaveCount(3); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); @@ -277,14 +277,14 @@ public async Task Does_not_exceed_MaxModelValidationErrors() error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The FileName field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/attributes/fileName"); ErrorObject error3 = responseDocument.Errors[2]; error3.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error3.Title.Should().Be("Input validation failed."); error3.Detail.Should().Be("The Attributes field is required."); - error3.Source.ShouldNotBeNull(); + error3.Source.Should().NotBeNull(); error3.Source.Pointer.Should().Be("/data/attributes/attributes"); } @@ -359,9 +359,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("directoryName").With(value => value.Should().Be(newDirectory.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isCaseSensitive").With(value => value.Should().Be(newDirectory.IsCaseSensitive)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("directoryName").WhoseValue.Should().Be(newDirectory.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isCaseSensitive").WhoseValue.Should().Be(newDirectory.IsCaseSensitive); } [Fact] @@ -472,20 +472,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Name field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/attributes/directoryName"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The IsCaseSensitive field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/attributes/isCaseSensitive"); } @@ -522,13 +522,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be(@"The field Name must match the regular expression '^[\w\s]+$'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/directoryName"); } @@ -567,20 +567,20 @@ public async Task Cannot_update_resource_with_invalid_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The field Id must match the regular expression '^[0-9]+$'."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/id"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The field Id must match the regular expression '^[0-9]+$'."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/relationships/subdirectories/data[0]/id"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/NoModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/NoModelStateValidationTests.cs index 41133fd27f..4245ff2fc1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/NoModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/ModelState/NoModelStateValidationTests.cs @@ -46,8 +46,8 @@ public async Task Can_create_resource_with_invalid_attribute_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("directoryName").With(value => value.Should().Be("!@#$%^&*().-")); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("directoryName").WhoseValue.Should().Be("!@#$%^&*().-"); } [Fact] @@ -123,7 +123,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/RequestBody/WorkflowTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/RequestBody/WorkflowTests.cs index 290a168fb1..9b8fd9cbc9 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/RequestBody/WorkflowTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/InputValidation/RequestBody/WorkflowTests.cs @@ -44,7 +44,7 @@ public async Task Can_create_in_valid_stage() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); } [Fact] @@ -71,13 +71,13 @@ public async Task Cannot_create_in_invalid_stage() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Invalid workflow stage."); error.Detail.Should().Be("Initial stage of workflow must be 'Created'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/stage"); } @@ -117,13 +117,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Invalid workflow stage."); error.Detail.Should().Be("Cannot transition from 'OnHold' to 'Succeeded'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/stage"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs index a58f68219f..688ef470b8 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithNamespaceTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -60,14 +60,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{HostPrefix}{route}"); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{HostPrefix}{route}/relationships/photos"); value.Links.Related.Should().Be($"{HostPrefix}{route}/photos"); }); @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -104,37 +104,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -173,14 +173,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -216,19 +216,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -256,7 +256,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album"); responseDocument.Links.First.Should().BeNull(); @@ -265,7 +265,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos"); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Links.Should().BeNull(); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); } @@ -353,7 +353,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -362,34 +362,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}"; responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -450,31 +450,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("album").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs index aaa62c1338..5098e9d34f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/AbsoluteLinksWithoutNamespaceTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -60,14 +60,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{HostPrefix}{route}"); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{HostPrefix}{route}/relationships/photos"); value.Links.Related.Should().Be($"{HostPrefix}{route}/photos"); }); @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -104,37 +104,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -173,14 +173,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -216,19 +216,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -256,7 +256,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album"); responseDocument.Links.First.Should().BeNull(); @@ -265,7 +265,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos"); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Links.Should().BeNull(); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); } @@ -353,7 +353,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -362,34 +362,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}"; responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -450,31 +450,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("album").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/DocumentDescriptionLinkTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/DocumentDescriptionLinkTests.cs index a2183247e5..99da94cb2c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/DocumentDescriptionLinkTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/DocumentDescriptionLinkTests.cs @@ -40,7 +40,7 @@ public async Task Get_primary_resource_by_ID_converts_relative_documentation_lin // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.DescribedBy.Should().Be("http://localhost/description/json-schema?version=v1.0"); } @@ -62,7 +62,7 @@ public async Task Get_primary_resource_by_ID_converts_absolute_documentation_lin // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.DescribedBy.Should().Be("description/json-schema?version=v1.0"); } @@ -84,7 +84,7 @@ public async Task Get_primary_resource_by_ID_cannot_convert_absolute_documentati // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.DescribedBy.Should().Be("https://docs.api.com/description/json-schema?version=v1.0"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionIncludeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionIncludeTests.cs index a7a033d17d..bfaac74209 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionIncludeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionIncludeTests.cs @@ -40,15 +40,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photo").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photo").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().ContainSingle(resource => resource.Type == "photos").Subject.With(resource => { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionTests.cs index 50920697f0..32fecc526c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/LinkInclusionTests.cs @@ -44,50 +44,50 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photo").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photo").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().BeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("album").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Links.Should().BeNull(); }); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].With(resource => { - resource.Links.ShouldNotBeNull(); - resource.Links.Self.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().NotBeNull(); - resource.Relationships.ShouldContainKey("location").With(value => + resource.Relationships.Should().ContainKey("location").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); }); responseDocument.Included[1].With(resource => { - resource.Links.ShouldNotBeNull(); - resource.Links.Self.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().NotBeNull(); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); }); } @@ -115,15 +115,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photo").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photo").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().BeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Related.Should().NotBeNull(); }); responseDocument.Data.SingleValue.Relationships.Should().NotContainKey("album"); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs index 27a432f261..60471032e6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithNamespaceTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -60,14 +60,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{HostPrefix}{route}"); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{HostPrefix}{route}/relationships/photos"); value.Links.Related.Should().Be($"{HostPrefix}{route}/photos"); }); @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -104,37 +104,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -173,14 +173,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -216,19 +216,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -256,7 +256,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album"); responseDocument.Links.First.Should().BeNull(); @@ -265,7 +265,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos"); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Links.Should().BeNull(); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); } @@ -353,7 +353,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -362,34 +362,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}"; responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -450,31 +450,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("album").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs index 37f24c4ceb..bbb95668d8 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Links/RelativeLinksWithoutNamespaceTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -60,14 +60,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{HostPrefix}{route}"); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{HostPrefix}{route}/relationships/photos"); value.Links.Related.Should().Be($"{HostPrefix}{route}/photos"); }); @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -104,37 +104,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -173,14 +173,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{photo.Album.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); @@ -207,7 +207,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -216,19 +216,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{album.Photos.ElementAt(0).StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -256,7 +256,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photos/{photo.StringId}/album"); responseDocument.Links.First.Should().BeNull(); @@ -265,7 +265,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Should().BeNull(); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().Be($"{HostPrefix}{PathPrefix}/photoAlbums/{album.StringId}/photos"); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -300,7 +300,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Links.Should().BeNull(); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); } @@ -353,7 +353,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -362,34 +362,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Next.Should().BeNull(); responseDocument.Links.DescribedBy.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{responseDocument.Data.SingleValue.Id}"; responseDocument.Data.SingleValue.Links.Self.Should().Be(albumLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("photos").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(photoLink); - resource.Relationships.ShouldContainKey("album").With(value => + resource.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().BeNull(); @@ -450,31 +450,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string photoLink = $"{HostPrefix}{PathPrefix}/photos/{existingPhoto.StringId}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be(photoLink); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("album").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("album").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{photoLink}/relationships/album"); value.Links.Related.Should().Be($"{photoLink}/album"); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string albumLink = $"{HostPrefix}{PathPrefix}/photoAlbums/{existingAlbum.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(albumLink); - resource.Relationships.ShouldContainKey("photos").With(value => + resource.Relationships.Should().ContainKey("photos").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{albumLink}/relationships/photos"); value.Links.Related.Should().Be($"{albumLink}/photos"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/ResourceMetaTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/ResourceMetaTests.cs index 6913e57761..f160c21068 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/ResourceMetaTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Meta/ResourceMetaTests.cs @@ -56,10 +56,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); - responseDocument.Data.ManyValue[0].Meta.ShouldContainKey("hasHighPriority"); + responseDocument.Data.ManyValue.Should().HaveCount(3); + responseDocument.Data.ManyValue[0].Meta.Should().ContainKey("hasHighPriority"); responseDocument.Data.ManyValue[1].Meta.Should().BeNull(); - responseDocument.Data.ManyValue[2].Meta.ShouldContainKey("hasHighPriority"); + responseDocument.Data.ManyValue[2].Meta.Should().ContainKey("hasHighPriority"); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -94,9 +94,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Included.ShouldHaveCount(1); - responseDocument.Included[0].Meta.ShouldContainKey("hasHighPriority"); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Included.Should().HaveCount(1); + responseDocument.Included[0].Meta.Should().ContainKey("hasHighPriority"); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.Group.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.Group.cs index c37f65b9eb..a412d64d96 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.Group.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.Group.cs @@ -39,8 +39,8 @@ public async Task Create_group_sends_messages() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newGroupName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newGroupName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -49,9 +49,9 @@ public async Task Create_group_sends_messages() (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); - Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); var content = messageBroker.SentMessages[0].GetContentAs(); content.GroupId.Should().Be(newGroupId); @@ -117,8 +117,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newGroupName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newGroupName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -128,9 +128,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(3); + messageBroker.SentMessages.Should().HaveCount(3); - Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.GroupId.Should().Be(newGroupId); @@ -193,7 +193,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.GroupId.Should().Be(existingGroup.StringId); @@ -278,7 +278,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(3); + messageBroker.SentMessages.Should().HaveCount(3); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -325,7 +325,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.GroupId.Should().Be(existingGroup.StringId); @@ -363,7 +363,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingGroup.Users.ElementAt(0).Id); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(3); + messageBroker.SentMessages.Should().HaveCount(3); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -512,7 +512,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -575,7 +575,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(existingUserWithSameGroup2.Id); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs index 0f8c75e7a1..e8687d9993 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.User.cs @@ -41,9 +41,9 @@ public async Task Create_user_sends_messages() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("loginName").With(value => value.Should().Be(newLoginName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(newDisplayName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("loginName").WhoseValue.Should().Be(newLoginName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(newDisplayName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -52,9 +52,9 @@ public async Task Create_user_sends_messages() (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); - Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(newUserId); @@ -110,9 +110,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("loginName").With(value => value.Should().Be(newLoginName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("loginName").WhoseValue.Should().Be(newLoginName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().BeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -122,9 +122,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); - Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(newUserId); @@ -185,7 +185,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -254,7 +254,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -326,7 +326,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -400,7 +400,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -444,7 +444,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -482,7 +482,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(2); + messageBroker.SentMessages.Should().HaveCount(2); var content1 = messageBroker.SentMessages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -531,7 +531,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -581,7 +581,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -633,7 +633,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); var content = messageBroker.SentMessages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs index e025b7caad..b9ed0b5df4 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/FireAndForgetDelivery/FireForgetTests.cs @@ -53,7 +53,7 @@ public async Task Does_not_send_message_on_write_error() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -94,7 +94,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.ServiceUnavailable); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.ServiceUnavailable); @@ -107,7 +107,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - messageBroker.SentMessages.ShouldHaveCount(1); + messageBroker.SentMessages.Should().HaveCount(1); await _testContext.RunOnDatabaseAsync(async dbContext => { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.Group.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.Group.cs index 86c01c83b1..47c5698e38 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.Group.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.Group.cs @@ -44,8 +44,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newGroupName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newGroupName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -54,12 +54,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.GroupId.Should().Be(newGroupId); @@ -126,8 +126,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newGroupName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newGroupName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -137,12 +137,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainGroup), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(3); + messages.Should().HaveCount(3); var content1 = messages[0].GetContentAs(); content1.GroupId.Should().Be(newGroupId); @@ -209,7 +209,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.GroupId.Should().Be(existingGroup.StringId); @@ -298,7 +298,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(3); + messages.Should().HaveCount(3); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -349,7 +349,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.GroupId.Should().Be(existingGroup.StringId); @@ -391,7 +391,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingGroup.Users.ElementAt(0).Id); @@ -471,7 +471,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(3); + messages.Should().HaveCount(3); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -548,7 +548,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUserWithoutGroup.Id); @@ -615,7 +615,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(existingUserWithSameGroup2.Id); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs index d4c64ab622..006ba19764 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.User.cs @@ -46,9 +46,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("loginName").With(value => value.Should().Be(newLoginName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(newDisplayName)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("loginName").WhoseValue.Should().Be(newLoginName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(newDisplayName); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -57,12 +57,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(newUserId); @@ -119,9 +119,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("loginName").With(value => value.Should().Be(newLoginName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().BeNull()); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("loginName").WhoseValue.Should().Be(newLoginName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().BeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -131,12 +131,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => (typeof(DomainUser), ResourceDefinitionExtensibilityPoints.OnWriteSucceededAsync) }, options => options.WithStrictOrdering()); - Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newUserId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(newUserId); @@ -201,7 +201,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -274,7 +274,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -350,7 +350,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -428,7 +428,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -476,7 +476,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -518,7 +518,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(2); + messages.Should().HaveCount(2); var content1 = messages[0].GetContentAs(); content1.UserId.Should().Be(existingUser.Id); @@ -571,7 +571,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -625,7 +625,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); @@ -681,7 +681,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await _testContext.RunOnDatabaseAsync(async dbContext => { List messages = await dbContext.OutboxMessages.OrderBy(message => message.Id).ToListAsync(); - messages.ShouldHaveCount(1); + messages.Should().HaveCount(1); var content = messages[0].GetContentAs(); content.UserId.Should().Be(existingUser.Id); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs index c0d43533f3..7f4b1f072c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Microservices/TransactionalOutboxPattern/OutboxTests.cs @@ -79,7 +79,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs index 530186d540..cca888a7a1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/MultiTenancy/MultiTenancyTests.cs @@ -62,7 +62,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(shops[1].StringId); } @@ -92,7 +92,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(shops[1].StringId); } @@ -122,11 +122,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("webShops"); responseDocument.Data.ManyValue[0].Id.Should().Be(shops[1].StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webProducts"); responseDocument.Included[0].Id.Should().Be(shops[1].Products[0].StringId); } @@ -152,7 +152,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -182,7 +182,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -212,7 +212,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -242,7 +242,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -272,7 +272,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -306,11 +306,11 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("url").With(value => value.Should().Be(newShopUrl)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("url").WhoseValue.Should().Be(newShopUrl); + responseDocument.Data.SingleValue.Relationships.Should().NotBeNull(); - int newShopId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newShopId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -371,7 +371,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -425,7 +425,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -518,7 +518,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -574,7 +574,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -627,7 +627,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -662,7 +662,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -707,7 +707,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -742,7 +742,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -784,7 +784,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -829,7 +829,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -873,7 +873,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -915,7 +915,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -977,7 +977,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1008,7 +1008,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().BeNull(); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); @@ -1016,37 +1016,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Links.Prev.Should().BeNull(); responseDocument.Links.Next.Should().BeNull(); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].With(resource => { string shopLink = $"/nld/shops/{shop.StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(shopLink); - resource.Relationships.ShouldContainKey("products").With(value => + resource.Relationships.Should().ContainKey("products").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{shopLink}/relationships/products"); value.Links.Related.Should().Be($"{shopLink}/products"); }); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { string productLink = $"/nld/products/{shop.Products[0].StringId}"; - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be(productLink); - resource.Relationships.ShouldContainKey("shop").With(value => + resource.Relationships.Should().ContainKey("shop").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{productLink}/relationships/shop"); value.Links.Related.Should().Be($"{productLink}/shop"); }); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/KebabCasingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/KebabCasingTests.cs index c3e6c30fe4..afa1bdfcd0 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/KebabCasingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/KebabCasingTests.cs @@ -41,20 +41,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Type == "swimming-pools"); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Attributes.ShouldContainKey("is-indoor") != null); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Relationships.ShouldContainKey("water-slides") != null); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Relationships.ShouldContainKey("diving-boards") != null); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Type == "swimming-pools"); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("is-indoor").WhoseValue != null); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.Should().ContainKey2("water-slides").WhoseValue != null); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.Should().ContainKey2("diving-boards").WhoseValue != null); decimal height = pools[1].DivingBoards[0].HeightInMeters; + string link = $"/public-api/diving-boards/{pools[1].DivingBoards[0].StringId}"; - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("diving-boards"); responseDocument.Included[0].Id.Should().Be(pools[1].DivingBoards[0].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("height-in-meters").With(value => value.As().Should().BeApproximately(height)); + responseDocument.Included[0].Attributes.Should().ContainKey("height-in-meters").WhoseValue.As().Should().BeApproximately(height); responseDocument.Included[0].Relationships.Should().BeNull(); - responseDocument.Included[0].Links.ShouldNotBeNull().Self.Should().Be($"/public-api/diving-boards/{pools[1].DivingBoards[0].StringId}"); + responseDocument.Included[0].Links.RefShould().NotBeNull().And.Subject.Self.Should().Be(link); responseDocument.Meta.Should().ContainTotal(2); } @@ -83,10 +84,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("water-slides"); responseDocument.Data.ManyValue[0].Id.Should().Be(pool.WaterSlides[1].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); } [Fact] @@ -115,25 +116,25 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("swimming-pools"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("is-indoor").With(value => value.Should().Be(newPool.IsIndoor)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("is-indoor").WhoseValue.Should().Be(newPool.IsIndoor); - int newPoolId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newPoolId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); string poolLink = $"{route}/{newPoolId}"; - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("water-slides").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("water-slides").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{poolLink}/relationships/water-slides"); value.Links.Related.Should().Be($"{poolLink}/water-slides"); }); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("diving-boards").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("diving-boards").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{poolLink}/relationships/diving-boards"); value.Links.Related.Should().Be($"{poolLink}/diving-boards"); }); @@ -160,12 +161,12 @@ public async Task Applies_casing_convention_on_error_stack_trace() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body."); - error.Meta.ShouldContainKey("stack-trace"); + error.Meta.Should().ContainKey("stack-trace"); } [Fact] @@ -201,13 +202,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The field HeightInMeters must be between 1 and 20."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/height-in-meters"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs index 22ed5abc87..1b630cdc92 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs @@ -42,22 +42,23 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Type == "SwimmingPools"); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Attributes.ShouldContainKey("IsIndoor") != null); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Relationships.ShouldContainKey("WaterSlides") != null); - responseDocument.Data.ManyValue.Should().OnlyContain(resourceObject => resourceObject.Relationships.ShouldContainKey("DivingBoards") != null); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Type == "SwimmingPools"); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("IsIndoor").WhoseValue != null); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.Should().ContainKey2("WaterSlides").WhoseValue != null); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.Should().ContainKey2("DivingBoards").WhoseValue != null); decimal height = pools[1].DivingBoards[0].HeightInMeters; + string link = $"/PublicApi/DivingBoards/{pools[1].DivingBoards[0].StringId}"; - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("DivingBoards"); responseDocument.Included[0].Id.Should().Be(pools[1].DivingBoards[0].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("HeightInMeters").With(value => value.As().Should().BeApproximately(height)); + responseDocument.Included[0].Attributes.Should().ContainKey("HeightInMeters").WhoseValue.As().Should().BeApproximately(height); responseDocument.Included[0].Relationships.Should().BeNull(); - responseDocument.Included[0].Links.ShouldNotBeNull().Self.Should().Be($"/PublicApi/DivingBoards/{pools[1].DivingBoards[0].StringId}"); + responseDocument.Included[0].Links.RefShould().NotBeNull().And.Subject.Self.Should().Be(link); - responseDocument.Meta.ShouldContainKey("Total").With(value => + responseDocument.Meta.Should().ContainKey("Total").WhoseValue.With(value => { JsonElement element = value.Should().BeOfType().Subject; element.GetInt32().Should().Be(2); @@ -87,10 +88,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("WaterSlides"); responseDocument.Data.ManyValue[0].Id.Should().Be(pool.WaterSlides[1].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); } [Fact] @@ -119,25 +120,25 @@ public async Task Can_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("SwimmingPools"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("IsIndoor").With(value => value.Should().Be(newPool.IsIndoor)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("IsIndoor").WhoseValue.Should().Be(newPool.IsIndoor); - int newPoolId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newPoolId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); string poolLink = $"{route}/{newPoolId}"; - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("WaterSlides").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("WaterSlides").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{poolLink}/relationships/WaterSlides"); value.Links.Related.Should().Be($"{poolLink}/WaterSlides"); }); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("DivingBoards").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("DivingBoards").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"{poolLink}/relationships/DivingBoards"); value.Links.Related.Should().Be($"{poolLink}/DivingBoards"); }); @@ -164,12 +165,12 @@ public async Task Applies_casing_convention_on_error_stack_trace() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body."); - error.Meta.ShouldContainKey("StackTrace"); + error.Meta.Should().ContainKey("StackTrace"); } [Fact] @@ -205,13 +206,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The field HeightInMeters must be between 1 and 20."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/HeightInMeters"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs index bd5029736b..7c0c50cfc6 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NonJsonApiControllers/NonJsonApiControllerTests.cs @@ -31,7 +31,7 @@ public async Task Get_skips_middleware_and_formatters() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("application/json; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); @@ -60,7 +60,7 @@ public async Task Post_skips_middleware_and_formatters() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); @@ -81,7 +81,7 @@ public async Task Post_skips_error_handler() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); @@ -110,7 +110,7 @@ public async Task Put_skips_middleware_and_formatters() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); @@ -131,7 +131,7 @@ public async Task Patch_skips_middleware_and_formatters() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); @@ -152,7 +152,7 @@ public async Task Delete_skips_middleware_and_formatters() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be("text/plain; charset=utf-8"); string responseText = await httpResponse.Content.ReadAsStringAsync(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterParseTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterParseTests.cs index 864b599a37..05265f3e46 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterParseTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterParseTests.cs @@ -51,13 +51,13 @@ public void Reader_Read_Fails(string parameterName, string parameterValue, strin InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterTests.cs index 024930c98b..fa991e7544 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/IsUpperCase/IsUpperCaseFilterTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); } @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[1].StringId); } @@ -118,11 +118,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Posts[1].StringId); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterParseTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterParseTests.cs index dfecb680db..92c104f5a4 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterParseTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterParseTests.cs @@ -51,13 +51,13 @@ public void Reader_Read_Fails(string parameterName, string parameterValue, strin InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterTests.cs index dcd6b493ea..da5091eed5 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthFilterTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); } @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[1].StringId); } @@ -118,11 +118,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Posts[1].StringId); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortParseTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortParseTests.cs index e7e16196e4..9e55ecb901 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortParseTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortParseTests.cs @@ -47,13 +47,13 @@ public void Reader_Read_Fails(string parameterName, string parameterValue, strin InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortTests.cs index 1ac9b05824..078d48029a 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/StringLength/LengthSortTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); @@ -90,7 +90,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[2].StringId); @@ -129,7 +129,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); @@ -137,7 +137,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Data.ManyValue[1].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[1].Id.Should().Be(blogs[0].StringId); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Posts[1].StringId); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterParseTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterParseTests.cs index d8ad2f04c3..853ac7ac4d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterParseTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterParseTests.cs @@ -58,13 +58,13 @@ public void Reader_Read_Fails(string parameterName, string parameterValue, strin InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterTests.cs index d866964b82..0f25661029 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/Sum/SumFilterTests.cs @@ -57,7 +57,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); } @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); } @@ -130,11 +130,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("blogs"); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blog.Posts[1].StringId); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs index 3cee32fe8b..329af80475 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/CustomFunctions/TimeOffset/TimeOffsetTests.cs @@ -72,7 +72,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); int[] matchingRowIndices = matchingRowsExpected.Split(',').Select(int.Parse).ToArray(); - responseDocument.Data.ManyValue.ShouldHaveCount(matchingRowIndices.Length); + responseDocument.Data.ManyValue.Should().HaveCount(matchingRowIndices.Length); foreach (int rowIndex in matchingRowIndices) { @@ -93,13 +93,13 @@ public async Task Cannot_filter_comparison_on_missing_relative_time() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Time offset between quotes expected. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -116,13 +116,13 @@ public async Task Cannot_filter_comparison_on_invalid_relative_time() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Failed to convert '*' of type 'String' to type 'TimeSpan'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -139,13 +139,13 @@ public async Task Cannot_filter_comparison_on_relative_time_at_left_side() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"The 'timeOffset' function can only be used at the right side of comparisons. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -162,13 +162,13 @@ public async Task Cannot_filter_any_on_relative_time() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Value between quotes expected. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -185,13 +185,13 @@ public async Task Cannot_filter_text_match_on_relative_time() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Attribute of type 'String' expected. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -225,7 +225,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(calendar.Appointments.ElementAt(1).StringId); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs index 9bacb8097e..2022505e0d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDataTypeTests.cs @@ -71,8 +71,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey(attributeName).With(value => value.Should().Be(value)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey(attributeName).WhoseValue.Should().Be(propertyValue); } [Fact] @@ -99,8 +99,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDecimal").With(value => value.Should().Be(resource.SomeDecimal)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDecimal").WhoseValue.Should().Be(resource.SomeDecimal); } [Fact] @@ -127,8 +127,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someGuid").With(value => value.Should().Be(resource.SomeGuid)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someGuid").WhoseValue.Should().Be(resource.SomeGuid); } [Fact] @@ -155,10 +155,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeInLocalZone") - .With(value => value.Should().Be(resource.SomeDateTimeInLocalZone)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeInLocalZone").WhoseValue.Should().Be(resource.SomeDateTimeInLocalZone); } [Fact] @@ -185,10 +184,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeInUtcZone") - .With(value => value.Should().Be(resource.SomeDateTimeInUtcZone)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeInUtcZone").WhoseValue.Should().Be(resource.SomeDateTimeInUtcZone); } [Fact] @@ -215,8 +213,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeOffset").With(value => value.Should().Be(resource.SomeDateTimeOffset)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeOffset").WhoseValue.Should().Be(resource.SomeDateTimeOffset); } [Fact] @@ -243,8 +241,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someTimeSpan").With(value => value.Should().Be(resource.SomeTimeSpan)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someTimeSpan").WhoseValue.Should().Be(resource.SomeTimeSpan); } [Fact] @@ -271,8 +269,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateOnly").With(value => value.Should().Be(resource.SomeDateOnly)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateOnly").WhoseValue.Should().Be(resource.SomeDateOnly); } [Fact] @@ -299,8 +297,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someTimeOnly").With(value => value.Should().Be(resource.SomeTimeOnly)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someTimeOnly").WhoseValue.Should().Be(resource.SomeTimeOnly); } [Fact] @@ -328,13 +326,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Failed to convert 'ABC' of type 'String' to type 'Int32'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -392,8 +390,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey(attributeName).With(value => value.Should().BeNull()); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey(attributeName).WhoseValue.Should().BeNull(); } [Theory] @@ -446,7 +444,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey(attributeName).With(value => value.Should().NotBeNull()); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey(attributeName).WhoseValue.Should().NotBeNull(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs index 6b9f74be19..cf8f696929 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs @@ -50,7 +50,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); } @@ -74,13 +74,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^filter"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -107,7 +107,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[1].StringId); } @@ -131,13 +131,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^filter"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -166,11 +166,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().ContainSingle(post => post.Id == posts[1].StringId); responseDocument.Data.ManyValue.Should().ContainSingle(post => post.Id == posts[2].StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(posts[1].Author!.StringId); } @@ -196,7 +196,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); } @@ -225,7 +225,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); } @@ -251,7 +251,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); } @@ -282,7 +282,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); } @@ -310,9 +310,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(blog.Posts[1].StringId); } @@ -340,9 +340,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(blog.Owner.Posts[1].StringId); } @@ -373,9 +373,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(posts[1].Labels.First().StringId); } @@ -404,9 +404,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId); @@ -439,7 +439,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[0].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(posts[2].StringId); } @@ -480,7 +480,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[0].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(posts[1].StringId); } @@ -522,10 +522,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Owner!.StringId); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs index 222ce40af4..791c5ad18b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterOperatorTests.cs @@ -83,10 +83,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someString").With(value => value.Should().Be(resource.SomeString)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someString").WhoseValue.Should().Be(resource.SomeString); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be("http://localhost/filterableResources?filter=equals(someString,'This%2c+that+%26+more+%2b+some')"); responseDocument.Links.First.Should().Be("http://localhost/filterableResources?filter=equals(someString,%27This,%20that%20%26%20more%20%2B%20some%27)"); } @@ -122,9 +122,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someInt32").With(value => value.Should().Be(resource.SomeInt32)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("otherInt32").With(value => value.Should().Be(resource.OtherInt32)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someInt32").WhoseValue.Should().Be(resource.SomeInt32); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("otherInt32").WhoseValue.Should().Be(resource.OtherInt32); } [Fact] @@ -158,9 +158,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someNullableInt32").With(value => value.Should().Be(resource.SomeNullableInt32)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("otherNullableInt32").With(value => value.Should().Be(resource.OtherNullableInt32)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someNullableInt32").WhoseValue.Should().Be(resource.SomeNullableInt32); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("otherNullableInt32").WhoseValue.Should().Be(resource.OtherNullableInt32); } [Fact] @@ -194,9 +194,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someInt32").With(value => value.Should().Be(resource.SomeInt32)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someNullableInt32").With(value => value.Should().Be(resource.SomeNullableInt32)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someInt32").WhoseValue.Should().Be(resource.SomeInt32); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someNullableInt32").WhoseValue.Should().Be(resource.SomeNullableInt32); } [Fact] @@ -230,9 +230,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someInt32").With(value => value.Should().Be(resource.SomeInt32)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someNullableInt32").With(value => value.Should().Be(resource.SomeNullableInt32)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someInt32").WhoseValue.Should().Be(resource.SomeInt32); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someNullableInt32").WhoseValue.Should().Be(resource.SomeNullableInt32); } [Fact] @@ -266,9 +266,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someInt32").With(value => value.Should().Be(resource.SomeInt32)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someUnsignedInt64").With(value => value.Should().Be(resource.SomeUnsignedInt64)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someInt32").WhoseValue.Should().Be(resource.SomeInt32); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someUnsignedInt64").WhoseValue.Should().Be(resource.SomeUnsignedInt64); } [Fact] @@ -283,7 +283,7 @@ public async Task Cannot_filter_equality_on_two_attributes_of_incompatible_types // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -330,8 +330,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someInt32").With(value => value.Should().Be(resource.SomeInt32)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someInt32").WhoseValue.Should().Be(resource.SomeInt32); } [Theory] @@ -372,8 +372,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDouble").With(value => value.Should().Be(resource.SomeDouble)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDouble").WhoseValue.Should().Be(resource.SomeDouble); } [Theory] @@ -422,10 +422,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeInLocalZone") - .With(value => value.Should().Be(resource.SomeDateTimeInLocalZone)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeInLocalZone").WhoseValue.Should().Be(resource.SomeDateTimeInLocalZone); } [Theory] @@ -474,10 +473,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeInUtcZone") - .With(value => value.Should().Be(resource.SomeDateTimeInUtcZone)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeInUtcZone").WhoseValue.Should().Be(resource.SomeDateTimeInUtcZone); } [Theory] @@ -526,9 +524,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateTimeOffset").With(value => value.Should().Be(resource.SomeDateTimeOffset)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateTimeOffset").WhoseValue.Should().Be(resource.SomeDateTimeOffset); } [Theory] @@ -568,8 +566,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someTimeSpan").With(value => value.Should().Be(resource.SomeTimeSpan)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someTimeSpan").WhoseValue.Should().Be(resource.SomeTimeSpan); } [Theory] @@ -617,8 +615,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someDateOnly").With(value => value.Should().Be(resource.SomeDateOnly)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someDateOnly").WhoseValue.Should().Be(resource.SomeDateOnly); } [Theory] @@ -658,8 +656,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someTimeOnly").With(value => value.Should().Be(resource.SomeTimeOnly)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someTimeOnly").WhoseValue.Should().Be(resource.SomeTimeOnly); } [Theory] @@ -696,8 +694,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someString").With(value => value.Should().Be(resource.SomeString)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someString").WhoseValue.Should().Be(resource.SomeString); } [Fact] @@ -713,13 +711,13 @@ public async Task Cannot_filter_text_match_on_non_string_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Attribute of type 'String' expected. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -736,13 +734,13 @@ public async Task Cannot_filter_text_match_on_nested_non_string_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Attribute of type 'String' expected. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -778,8 +776,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("someString").With(value => value.Should().Be(resource.SomeString)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("someString").WhoseValue.Should().Be(resource.SomeString); } [Fact] @@ -809,7 +807,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resource.StringId); } @@ -856,7 +854,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resources[1].StringId); } @@ -888,7 +886,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resource.StringId); } @@ -925,7 +923,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resource.Children.ElementAt(0).StringId); } @@ -942,13 +940,13 @@ public async Task Cannot_filter_on_count_with_incompatible_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Failed to convert 'ABC' of type 'String' to type 'Int32'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -989,7 +987,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resource1.StringId); } @@ -1029,7 +1027,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(resource1.StringId); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs index 5f5c0cbeef..2f6c468f08 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterTests.cs @@ -37,13 +37,13 @@ public async Task Cannot_filter_in_unknown_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'webAccounts'. {parameterName}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName.Text); } @@ -60,13 +60,13 @@ public async Task Cannot_filter_in_unknown_nested_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'blogPosts'. {parameterName}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName.Text); } @@ -83,13 +83,13 @@ public async Task Cannot_filter_on_attribute_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Filtering on attribute 'dateOfBirth' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -106,13 +106,13 @@ public async Task Cannot_filter_on_ToMany_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"Filtering on relationship 'appointments' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } @@ -137,8 +137,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[0].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(accounts[0].UserName)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(accounts[0].UserName); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs index 6030600791..3038ae9817 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Includes/IncludeTests.cs @@ -49,14 +49,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(post.Author.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(post.Author.DisplayName)); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(post.Author.DisplayName); } [Fact] @@ -80,14 +80,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(post.Author.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(post.Author.DisplayName)); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(post.Author.DisplayName); } [Fact] @@ -112,14 +112,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.Owner.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(blog.Owner.DisplayName)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(blog.Owner.DisplayName); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blog.Owner.Posts[0].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Owner.Posts[0].Caption)); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Owner.Posts[0].Caption); } [Fact] @@ -144,14 +144,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Posts[0].Caption)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Posts[0].Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blog.Posts[0].Author!.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(blog.Posts[0].Author!.DisplayName)); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(blog.Posts[0].Author!.DisplayName); } [Fact] @@ -176,19 +176,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(comment.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("text").With(value => value.Should().Be(comment.Text)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("text").WhoseValue.Should().Be(comment.Text); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(comment.Author.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(comment.Author.UserName)); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(comment.Author.UserName); responseDocument.Included[1].Type.Should().Be("blogPosts"); responseDocument.Included[1].Id.Should().Be(comment.Parent.StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(comment.Parent.Caption)); + responseDocument.Included[1].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(comment.Parent.Caption); } [Fact] @@ -212,16 +212,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); DateTime createdAt = post.Comments.Single().CreatedAt; - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("comments"); responseDocument.Included[0].Id.Should().Be(post.Comments.Single().StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(createdAt)); + responseDocument.Included[0].Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(createdAt); } [Fact] @@ -245,14 +245,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("labels"); responseDocument.Included[0].Id.Should().Be(post.Labels.Single().StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(post.Labels.Single().Name)); + responseDocument.Included[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(post.Labels.Single().Name); } [Fact] @@ -276,15 +276,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("labels"); responseDocument.Data.ManyValue[0].Id.Should().Be(post.Labels.ElementAt(0).StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(post.Labels.Single().Name)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(post.Labels.Single().Name); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(post.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); } [Fact] @@ -310,25 +310,25 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(comment.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("text").With(value => value.Should().Be(comment.Text)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("text").WhoseValue.Should().Be(comment.Text); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(comment.Parent.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(comment.Parent.Caption)); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(comment.Parent.Caption); responseDocument.Included[1].Type.Should().Be("webAccounts"); responseDocument.Included[1].Id.Should().Be(comment.Parent.Author.StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(comment.Parent.Author.DisplayName)); + responseDocument.Included[1].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(comment.Parent.Author.DisplayName); bool useDarkTheme = comment.Parent.Author.Preferences.UseDarkTheme; responseDocument.Included[2].Type.Should().Be("accountPreferences"); responseDocument.Included[2].Id.Should().Be(comment.Parent.Author.Preferences.StringId); - responseDocument.Included[2].Attributes.ShouldContainKey("useDarkTheme").With(value => value.Should().Be(useDarkTheme)); + responseDocument.Included[2].Attributes.Should().ContainKey("useDarkTheme").WhoseValue.Should().Be(useDarkTheme); } [Fact] @@ -353,21 +353,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("title").With(value => value.Should().Be(blog.Title)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(blog.Title); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blog.Posts[0].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Posts[0].Caption)); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Posts[0].Caption); DateTime createdAt = blog.Posts[0].Comments.Single().CreatedAt; responseDocument.Included[1].Type.Should().Be("comments"); responseDocument.Included[1].Id.Should().Be(blog.Posts[0].Comments.Single().StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("createdAt").With(value => value.Should().Be(createdAt)); + responseDocument.Included[1].Attributes.Should().ContainKey("createdAt").WhoseValue.Should().Be(createdAt); } [Fact] @@ -394,29 +394,29 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(comment.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("text").With(value => value.Should().Be(comment.Text)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("text").WhoseValue.Should().Be(comment.Text); - responseDocument.Included.ShouldHaveCount(4); + responseDocument.Included.Should().HaveCount(4); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(comment.Parent.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(comment.Parent.Caption)); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(comment.Parent.Caption); responseDocument.Included[1].Type.Should().Be("comments"); responseDocument.Included[1].Id.Should().Be(comment.Parent.Comments.ElementAt(0).StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("text").With(value => value.Should().Be(comment.Parent.Comments.ElementAt(0).Text)); + responseDocument.Included[1].Attributes.Should().ContainKey("text").WhoseValue.Should().Be(comment.Parent.Comments.ElementAt(0).Text); string userName = comment.Parent.Comments.ElementAt(0).Author!.UserName; responseDocument.Included[2].Type.Should().Be("webAccounts"); responseDocument.Included[2].Id.Should().Be(comment.Parent.Comments.ElementAt(0).Author!.StringId); - responseDocument.Included[2].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(userName)); + responseDocument.Included[2].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(userName); responseDocument.Included[3].Type.Should().Be("comments"); responseDocument.Included[3].Id.Should().Be(comment.Parent.Comments.ElementAt(1).StringId); - responseDocument.Included[3].Attributes.ShouldContainKey("text").With(value => value.Should().Be(comment.Parent.Comments.ElementAt(1).Text)); + responseDocument.Included[3].Attributes.Should().ContainKey("text").WhoseValue.Should().Be(comment.Parent.Comments.ElementAt(1).Text); } [Fact] @@ -445,34 +445,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("posts").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("blogPosts"); value.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); }); - responseDocument.Included.ShouldHaveCount(7); + responseDocument.Included.Should().HaveCount(7); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blog.Posts[0].StringId); - responseDocument.Included[0].Relationships.ShouldContainKey("author").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(blog.Posts[0].Author!.StringId); }); - responseDocument.Included[0].Relationships.ShouldContainKey("comments").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("comments").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("comments"); value.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).StringId); }); @@ -480,17 +480,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[1].Type.Should().Be("webAccounts"); responseDocument.Included[1].Id.Should().Be(blog.Posts[0].Author!.StringId); - responseDocument.Included[1].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[1].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("accountPreferences"); value.Data.SingleValue.Id.Should().Be(blog.Posts[0].Author!.Preferences!.StringId); }); - responseDocument.Included[1].Relationships.ShouldContainKey("posts").With(value => + responseDocument.Included[1].Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); @@ -500,10 +500,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[3].Type.Should().Be("comments"); responseDocument.Included[3].Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).StringId); - responseDocument.Included[3].Relationships.ShouldContainKey("author").With(value => + responseDocument.Included[3].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).Author!.StringId); }); @@ -511,41 +511,41 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[4].Type.Should().Be("webAccounts"); responseDocument.Included[4].Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).Author!.StringId); - responseDocument.Included[4].Relationships.ShouldContainKey("posts").With(value => + responseDocument.Included[4].Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("blogPosts"); value.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).Author!.Posts[0].StringId); }); - responseDocument.Included[4].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[4].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); responseDocument.Included[5].Type.Should().Be("blogPosts"); responseDocument.Included[5].Id.Should().Be(blog.Posts[0].Comments.ElementAt(0).Author!.Posts[0].StringId); - responseDocument.Included[5].Relationships.ShouldContainKey("author").With(value => + responseDocument.Included[5].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); - responseDocument.Included[5].Relationships.ShouldContainKey("comments").With(value => + responseDocument.Included[5].Relationships.Should().ContainKey("comments").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); responseDocument.Included[6].Type.Should().Be("comments"); responseDocument.Included[6].Id.Should().Be(blog.Posts[0].Comments.ElementAt(1).StringId); - responseDocument.Included[5].Relationships.ShouldContainKey("author").With(value => + responseDocument.Included[5].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); } @@ -588,23 +588,23 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[0].Id.Should().Be(post1.StringId); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(author.StringId); }); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("reviewer").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("reviewer").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(reviewer.StringId); }); @@ -612,38 +612,38 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Data.ManyValue[1].Type.Should().Be("blogPosts"); responseDocument.Data.ManyValue[1].Id.Should().Be(post2.StringId); - responseDocument.Data.ManyValue[1].Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.ManyValue[1].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(person.StringId); }); - responseDocument.Data.ManyValue[1].Relationships.ShouldContainKey("reviewer").With(value => + responseDocument.Data.ManyValue[1].Relationships.Should().ContainKey("reviewer").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(person.StringId); }); - responseDocument.Included.ShouldHaveCount(7); + responseDocument.Included.Should().HaveCount(7); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(author.StringId); - responseDocument.Included[0].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("accountPreferences"); value.Data.SingleValue.Id.Should().Be(author.Preferences.StringId); }); - responseDocument.Included[0].Relationships.ShouldContainKey("loginAttempts").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("loginAttempts").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); @@ -653,16 +653,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[2].Type.Should().Be("webAccounts"); responseDocument.Included[2].Id.Should().Be(reviewer.StringId); - responseDocument.Included[2].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[2].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); }); - responseDocument.Included[2].Relationships.ShouldContainKey("loginAttempts").With(value => + responseDocument.Included[2].Relationships.Should().ContainKey("loginAttempts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("loginAttempts"); value.Data.ManyValue[0].Id.Should().Be(reviewer.LoginAttempts[0].StringId); }); @@ -673,18 +673,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[4].Type.Should().Be("webAccounts"); responseDocument.Included[4].Id.Should().Be(person.StringId); - responseDocument.Included[4].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[4].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("accountPreferences"); value.Data.SingleValue.Id.Should().Be(person.Preferences.StringId); }); - responseDocument.Included[4].Relationships.ShouldContainKey("loginAttempts").With(value => + responseDocument.Included[4].Relationships.Should().ContainKey("loginAttempts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("loginAttempts"); value.Data.ManyValue[0].Id.Should().Be(person.LoginAttempts[0].StringId); }); @@ -720,27 +720,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("blogs"); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("posts").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("blogPosts"); value.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); }); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blog.Posts[0].StringId); - responseDocument.Included[0].Relationships.ShouldContainKey("author").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("webAccounts"); value.Data.SingleValue.Id.Should().Be(blog.Posts[0].Author!.StringId); }); @@ -748,10 +748,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[1].Type.Should().Be("webAccounts"); responseDocument.Included[1].Id.Should().Be(blog.Posts[0].Author!.StringId); - responseDocument.Included[1].Relationships.ShouldContainKey("posts").With(value => + responseDocument.Included[1].Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldNotBeEmpty(); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().NotBeEmpty(); value.Data.ManyValue[0].Type.Should().Be("blogPosts"); value.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); }); @@ -781,14 +781,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(account.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(account.UserName)); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(account.UserName); } [Fact] @@ -816,12 +816,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(account.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(account.UserName)); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(account.UserName); } [Fact] @@ -844,7 +844,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Included.Should().BeEmpty(); } @@ -862,13 +862,13 @@ public async Task Cannot_include_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'webAccounts'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } @@ -885,13 +885,13 @@ public async Task Cannot_include_unknown_nested_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'blogPosts'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } @@ -908,13 +908,13 @@ public async Task Cannot_include_relationship_when_inclusion_blocked() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"Including the relationship 'parent' on 'blogPosts' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } @@ -931,13 +931,13 @@ public async Task Cannot_include_relationship_when_nested_inclusion_blocked() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"Including the relationship 'parent' on 'blogPosts' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } @@ -962,11 +962,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("calendars"); responseDocument.Data.SingleValue.Id.Should().Be(calendar.StringId); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); responseDocument.Data.SingleValue.Relationships.Should().NotContainKey("appointments"); responseDocument.Included.Should().BeEmpty(); @@ -1001,21 +1001,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("calendars"); responseDocument.Data.SingleValue.Id.Should().Be(calendar.StringId); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("mostRecentAppointment").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("mostRecentAppointment").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("appointments"); value.Data.SingleValue.Id.Should().Be(calendar.MostRecentAppointment.StringId); }); responseDocument.Data.SingleValue.Relationships.Should().NotContainKey("appointments"); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("appointments"); responseDocument.Included[0].Id.Should().Be(calendar.MostRecentAppointment.StringId); } @@ -1042,26 +1042,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.ShouldContainKey("reviewer") != null); + responseDocument.Data.ManyValue.Should().OnlyContain(resource => resource.Relationships.Should().ContainKey2("reviewer").WhoseValue != null); ResourceObject[] postWithReviewer = responseDocument.Data.ManyValue .Where(resource => resource.Relationships!.First(pair => pair.Key == "reviewer").Value!.Data.SingleValue != null).ToArray(); - postWithReviewer.ShouldHaveCount(1); - postWithReviewer[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(posts[0].Caption)); + postWithReviewer.Should().HaveCount(1); + postWithReviewer[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(posts[0].Caption); ResourceObject[] postWithoutReviewer = responseDocument.Data.ManyValue .Where(resource => resource.Relationships!.First(pair => pair.Key == "reviewer").Value!.Data.SingleValue == null).ToArray(); - postWithoutReviewer.ShouldHaveCount(1); - postWithoutReviewer[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(posts[1].Caption)); + postWithoutReviewer.Should().HaveCount(1); + postWithoutReviewer[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(posts[1].Caption); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(posts[0].Reviewer!.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(posts[0].Reviewer!.UserName)); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(posts[0].Reviewer!.UserName); } [Fact] @@ -1104,13 +1104,13 @@ public async Task Cannot_exceed_configured_maximum_inclusion_depth() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"Including 'posts.comments' exceeds the maximum inclusion depth of 1. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("include"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs index 6cb1b9f851..64255c0b54 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs @@ -54,10 +54,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().Be($"{HostPrefix}/blogPosts?page%5Bnumber%5D=2&page%5Bsize%5D=1"); @@ -85,13 +85,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^page[number]"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -119,10 +119,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[2].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogs/{blog.StringId}/posts?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().Be($"{HostPrefix}/blogs/{blog.StringId}/posts?page%5Bnumber%5D=5&page%5Bsize%5D=1"); @@ -151,10 +151,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(account.LoginAttempts[1].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/webAccounts/{account.StringId}/loginAttempts?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().BeNull(); @@ -182,13 +182,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^page[size]"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } @@ -215,13 +215,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Id.Should().Be(blogs[0].Posts[1].StringId); responseDocument.Included[1].Id.Should().Be(blogs[1].Posts[1].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogs?include=posts&page%5Bsize%5D=2,posts%3A1"); responseDocument.Links.Last.Should().Be($"{HostPrefix}/blogs?include=posts&page%5Bnumber%5D=2&page%5Bsize%5D=2,posts%3A1"); @@ -251,11 +251,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(blog.Owner.Posts[1].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().BeNull(); responseDocument.Links.Last.Should().BeNull(); @@ -284,10 +284,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[1].StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogs/{blog.StringId}/relationships/posts?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().Be($"{HostPrefix}/blogs/{blog.StringId}/relationships/posts?page%5Bnumber%5D=4&page%5Bsize%5D=1"); @@ -316,12 +316,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(account.LoginAttempts[1].StringId); string basePath = $"{HostPrefix}/webAccounts/{account.StringId}/relationships/loginAttempts"; - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{basePath}?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().BeNull(); @@ -352,13 +352,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Id.Should().Be(posts[0].Labels.ElementAt(1).StringId); responseDocument.Included[1].Id.Should().Be(posts[1].Labels.ElementAt(1).StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?include=labels&page%5Bsize%5D=labels%3A1"); responseDocument.Links.Last.Should().Be(responseDocument.Links.First); @@ -388,10 +388,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.Labels.ElementAt(1).StringId); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts/{post.StringId}/relationships/labels?page%5Bsize%5D=1"); responseDocument.Links.Last.Should().Be($"{HostPrefix}/blogPosts/{post.StringId}/relationships/labels?page%5Bnumber%5D=4&page%5Bsize%5D=1"); @@ -424,10 +424,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Owner!.StringId); @@ -440,7 +440,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => const string linkPrefix = $"{HostPrefix}/blogs?include=owner.posts.comments"; - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{linkPrefix}&page%5Bsize%5D=1,owner.posts%3A1,owner.posts.comments%3A1"); responseDocument.Links.Last.Should().Be($"{linkPrefix}&page%5Bsize%5D=1,owner.posts%3A1,owner.posts.comments%3A1&page%5Bnumber%5D=2"); @@ -461,13 +461,13 @@ public async Task Cannot_paginate_in_unknown_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'webAccounts'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -484,13 +484,13 @@ public async Task Cannot_paginate_in_unknown_nested_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'blogPosts'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } @@ -519,13 +519,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(blog.Posts[1].StringId); - responseDocument.Included.ShouldHaveCount(4); + responseDocument.Included.Should().HaveCount(4); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be(responseDocument.Links.Self); responseDocument.Links.Last.Should().Be($"{responseDocument.Links.Self}&page%5Bnumber%5D=2"); @@ -557,9 +557,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(25); + responseDocument.Data.ManyValue.Should().HaveCount(25); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().BeNull(); responseDocument.Links.Last.Should().BeNull(); @@ -603,8 +603,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.ShouldNotBeNull(); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Should().NotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); if (firstLink != null) diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs index 29d9aa146a..1bcfb0c6f5 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithoutTotalCountTests.cs @@ -44,7 +44,7 @@ public async Task Hides_pagination_links_when_unconstrained_page_size() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().BeNull(); responseDocument.Links.Last.Should().BeNull(); @@ -73,7 +73,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?page%5Bsize%5D=8&foo=bar"); responseDocument.Links.Last.Should().BeNull(); @@ -99,7 +99,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?foo=bar"); responseDocument.Links.Last.Should().BeNull(); @@ -130,7 +130,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Data.ManyValue.Should().HaveCountLessThan(DefaultPageSize); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?foo=bar"); responseDocument.Links.Last.Should().BeNull(); @@ -159,9 +159,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(DefaultPageSize); + responseDocument.Data.ManyValue.Should().HaveCount(DefaultPageSize); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/blogPosts?foo=bar"); responseDocument.Links.Last.Should().BeNull(); @@ -190,9 +190,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(DefaultPageSize); + responseDocument.Data.ManyValue.Should().HaveCount(DefaultPageSize); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be($"{HostPrefix}{route}"); responseDocument.Links.First.Should().Be($"{HostPrefix}/webAccounts/{account.StringId}/posts?foo=bar"); responseDocument.Links.Last.Should().BeNull(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs index f551f4b108..687bffdc19 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationTests.cs @@ -39,13 +39,13 @@ public async Task Cannot_use_negative_page_number() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page number cannot be negative or zero. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -62,13 +62,13 @@ public async Task Cannot_use_zero_page_number() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page number cannot be negative or zero. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -122,13 +122,13 @@ public async Task Cannot_use_negative_page_size() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page size cannot be negative. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationWithMaximumTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationWithMaximumTests.cs index 5a8d375543..18141b6758 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationWithMaximumTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/RangeValidationWithMaximumTests.cs @@ -68,13 +68,13 @@ public async Task Cannot_use_page_number_over_maximum() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page number cannot be higher than {MaximumPageNumber}. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -91,13 +91,13 @@ public async Task Cannot_use_zero_page_size() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page size cannot be unconstrained. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } @@ -143,13 +143,13 @@ public async Task Cannot_use_page_size_over_maximum() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"Page size cannot be higher than {MaximumPageSize}. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringTests.cs index 4f6ee95ad2..8bc14467cd 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/QueryStringTests.cs @@ -34,7 +34,7 @@ public async Task Cannot_use_unknown_query_string_parameter() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -43,7 +43,7 @@ public async Task Cannot_use_unknown_query_string_parameter() error.Detail.Should().Be("Query string parameter 'foo' is unknown. " + "Set 'AllowUnknownQueryStringParameters' to 'true' in options to ignore unknown parameters."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("foo"); } @@ -100,13 +100,13 @@ public async Task Cannot_use_empty_query_string_parameter_value(string parameter // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be($"Missing value for '{parameterName}' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SerializerIgnoreConditionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SerializerIgnoreConditionTests.cs index 89db819a2c..7fa5aa7fcb 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SerializerIgnoreConditionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SerializerIgnoreConditionTests.cs @@ -53,13 +53,13 @@ await RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Included.Should().HaveCount(1); if (expectNullValueInDocument) { - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("timeZone"); - responseDocument.Included[0].Attributes.ShouldContainKey("description"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("timeZone"); + responseDocument.Included[0].Attributes.Should().ContainKey("description"); } else { @@ -69,8 +69,8 @@ await RunOnDatabaseAsync(async dbContext => if (expectDefaultValueInDocument) { - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("defaultAppointmentDurationInMinutes"); - responseDocument.Included[0].Attributes.ShouldContainKey("startTime"); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("defaultAppointmentDurationInMinutes"); + responseDocument.Included[0].Attributes.Should().ContainKey("startTime"); } else { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Sorting/SortTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Sorting/SortTests.cs index 0afda4b48e..45cd010379 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Sorting/SortTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Sorting/SortTests.cs @@ -47,7 +47,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(posts[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(posts[2].StringId); @@ -73,13 +73,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^sort"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -107,7 +107,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(blog.Posts[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(blog.Posts[2].StringId); @@ -133,13 +133,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"{CollectionErrorMessage} Failed at position 1: ^sort"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -166,7 +166,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(blogs[0].StringId); } @@ -194,7 +194,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(posts[0].StringId); } @@ -223,10 +223,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(account.StringId); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Id.Should().Be(account.Posts[1].StringId); responseDocument.Included[1].Id.Should().Be(account.Posts[0].StringId); responseDocument.Included[2].Id.Should().Be(account.Posts[2].StringId); @@ -257,10 +257,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.Owner.StringId); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Id.Should().Be(blog.Owner.Posts[1].StringId); responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[0].StringId); responseDocument.Included[2].Id.Should().Be(blog.Owner.Posts[2].StringId); @@ -290,10 +290,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included[0].Id.Should().Be(post.Labels.ElementAt(1).StringId); responseDocument.Included[1].Id.Should().Be(post.Labels.ElementAt(0).StringId); responseDocument.Included[2].Id.Should().Be(post.Labels.ElementAt(2).StringId); @@ -337,11 +337,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(blogs[0].StringId); - responseDocument.Included.ShouldHaveCount(7); + responseDocument.Included.Should().HaveCount(7); responseDocument.Included[0].Type.Should().Be("blogPosts"); responseDocument.Included[0].Id.Should().Be(blogs[0].Posts[2].StringId); @@ -391,7 +391,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(posts[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(posts[0].StringId); } @@ -428,11 +428,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(blogs[0].StringId); - responseDocument.Included.ShouldHaveCount(5); + responseDocument.Included.Should().HaveCount(5); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blogs[1].Owner!.StringId); @@ -463,13 +463,13 @@ public async Task Cannot_sort_in_unknown_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'webAccounts'. {parameterName}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName.Text); } @@ -486,13 +486,13 @@ public async Task Cannot_sort_in_unknown_nested_scope() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"Field '{Unknown.Relationship}' does not exist on resource type 'blogPosts'. {parameterName}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName.Text); } @@ -509,13 +509,13 @@ public async Task Cannot_sort_on_attribute_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"Sorting on attribute 'dateOfBirth' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -547,7 +547,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(accounts[2].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(accounts[0].StringId); @@ -578,7 +578,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[2].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(accounts[1].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(accounts[0].StringId); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs index 1c7477d22d..088c6cc7bf 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs @@ -56,19 +56,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); - responseDocument.Data.ManyValue[0].Relationships.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); + responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -100,10 +100,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -135,18 +135,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); responseDocument.Data.ManyValue[0].Attributes.Should().BeNull(); - responseDocument.Data.ManyValue[0].Relationships.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -178,26 +178,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(blog.Posts[0].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Posts[0].Caption)); - responseDocument.Data.ManyValue[0].Relationships.ShouldHaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Posts[0].Caption); + responseDocument.Data.ManyValue[0].Relationships.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Relationships.ShouldContainKey("labels").With(value => + responseDocument.Data.ManyValue[0].Relationships.Should().ContainKey("labels").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which; blogCaptured.Id.Should().Be(blog.Id); blogCaptured.Title.Should().BeNull(); - blogCaptured.Posts.ShouldHaveCount(1); + blogCaptured.Posts.Should().HaveCount(1); blogCaptured.Posts[0].Caption.Should().Be(blog.Posts[0].Caption); blogCaptured.Posts[0].Url.Should().BeNull(); } @@ -225,19 +225,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("url").With(value => value.Should().Be(post.Url)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("url").WhoseValue.Should().Be(post.Url); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -269,41 +269,41 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Id.Should().Be(post.Author.StringId); - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldHaveCount(2); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(post.Author.DisplayName)); - responseDocument.Included[0].Attributes.ShouldContainKey("emailAddress").With(value => value.Should().Be(post.Author.EmailAddress)); - responseDocument.Included[0].Relationships.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().HaveCount(2); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(post.Author.DisplayName); + responseDocument.Included[0].Attributes.Should().ContainKey("emailAddress").WhoseValue.Should().Be(post.Author.EmailAddress); + responseDocument.Included[0].Relationships.Should().HaveCount(1); - responseDocument.Included[0].Relationships.ShouldContainKey("preferences").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("preferences").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; postCaptured.Id.Should().Be(post.Id); postCaptured.Caption.Should().Be(post.Caption); - postCaptured.Author.ShouldNotBeNull(); + postCaptured.Author.Should().NotBeNull(); postCaptured.Author.DisplayName.Should().Be(post.Author.DisplayName); postCaptured.Author.EmailAddress.Should().Be(post.Author.EmailAddress); postCaptured.Author.UserName.Should().BeNull(); @@ -333,39 +333,39 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(account.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(account.DisplayName)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(account.DisplayName); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("posts").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(account.Posts[0].StringId); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(account.Posts[0].Caption)); - responseDocument.Included[0].Relationships.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(account.Posts[0].Caption); + responseDocument.Included[0].Relationships.Should().HaveCount(1); - responseDocument.Included[0].Relationships.ShouldContainKey("labels").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("labels").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var accountCaptured = (WebAccount)store.Resources.Should().ContainSingle(resource => resource is WebAccount).Which; accountCaptured.Id.Should().Be(account.Id); accountCaptured.DisplayName.Should().Be(account.DisplayName); - accountCaptured.Posts.ShouldHaveCount(1); + accountCaptured.Posts.Should().HaveCount(1); accountCaptured.Posts[0].Caption.Should().Be(account.Posts[0].Caption); accountCaptured.Posts[0].Url.Should().BeNull(); } @@ -395,40 +395,40 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.Owner.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(blog.Owner.DisplayName)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(blog.Owner.DisplayName); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("posts").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(blog.Owner.Posts[0].StringId); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Owner.Posts[0].Caption)); - responseDocument.Included[0].Relationships.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Owner.Posts[0].Caption); + responseDocument.Included[0].Relationships.Should().HaveCount(1); - responseDocument.Included[0].Relationships.ShouldContainKey("comments").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("comments").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which; blogCaptured.Id.Should().Be(blog.Id); - blogCaptured.Owner.ShouldNotBeNull(); + blogCaptured.Owner.Should().NotBeNull(); blogCaptured.Owner.DisplayName.Should().Be(blog.Owner.DisplayName); - blogCaptured.Owner.Posts.ShouldHaveCount(1); + blogCaptured.Owner.Posts.Should().HaveCount(1); blogCaptured.Owner.Posts[0].Caption.Should().Be(blog.Owner.Posts[0].Caption); blogCaptured.Owner.Posts[0].Url.Should().BeNull(); } @@ -457,30 +457,30 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("labels").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("labels").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(post.Labels.ElementAt(0).StringId); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("color").With(value => value.Should().Be(post.Labels.Single().Color)); + responseDocument.Included.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("color").WhoseValue.Should().Be(post.Labels.Single().Color); responseDocument.Included[0].Relationships.Should().BeNull(); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; postCaptured.Id.Should().Be(post.Id); postCaptured.Caption.Should().Be(post.Caption); - postCaptured.Labels.ShouldHaveCount(1); + postCaptured.Labels.Should().HaveCount(1); postCaptured.Labels.Single().Color.Should().Be(post.Labels.Single().Color); postCaptured.Labels.Single().Name.Should().BeNull(); } @@ -510,26 +510,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("blogs"); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("title").With(value => value.Should().Be(blog.Title)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(blog.Title); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(2); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(blog.Owner.UserName)); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(blog.Owner.DisplayName)); + responseDocument.Included[0].Attributes.Should().HaveCount(2); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(blog.Owner.UserName); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(blog.Owner.DisplayName); responseDocument.Included[0].Relationships.Should().BeNull(); responseDocument.Included[1].Type.Should().Be("blogPosts"); responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[0].StringId); - responseDocument.Included[1].Attributes.ShouldHaveCount(1); - responseDocument.Included[1].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Owner.Posts[0].Caption)); + responseDocument.Included[1].Attributes.Should().HaveCount(1); + responseDocument.Included[1].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Owner.Posts[0].Caption); responseDocument.Included[1].Relationships.Should().BeNull(); var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which; @@ -541,7 +541,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => blogCaptured.Owner.DisplayName.Should().Be(blog.Owner.DisplayName); blogCaptured.Owner.DateOfBirth.Should().BeNull(); - blogCaptured.Owner.Posts.ShouldHaveCount(1); + blogCaptured.Owner.Posts.Should().HaveCount(1); blogCaptured.Owner.Posts[0].Caption.Should().Be(blog.Owner.Posts[0].Caption); blogCaptured.Owner.Posts[0].Url.Should().BeNull(); } @@ -571,53 +571,53 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("blogs"); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("title").With(value => value.Should().Be(blog.Title)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(blog.Title); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("owner").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("owner").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Id.Should().Be(blog.Owner.StringId); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("webAccounts"); responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("userName").With(value => value.Should().Be(blog.Owner.UserName)); - responseDocument.Included[0].Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(blog.Owner.DisplayName)); - responseDocument.Included[0].Attributes.ShouldContainKey("dateOfBirth").With(value => value.Should().Be(blog.Owner.DateOfBirth)); + responseDocument.Included[0].Attributes.Should().ContainKey("userName").WhoseValue.Should().Be(blog.Owner.UserName); + responseDocument.Included[0].Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(blog.Owner.DisplayName); + responseDocument.Included[0].Attributes.Should().ContainKey("dateOfBirth").WhoseValue.Should().Be(blog.Owner.DateOfBirth); - responseDocument.Included[0].Relationships.ShouldContainKey("posts").With(value => + responseDocument.Included[0].Relationships.Should().ContainKey("posts").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(blog.Owner.Posts[0].StringId); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); responseDocument.Included[1].Type.Should().Be("blogPosts"); responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[0].StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(blog.Owner.Posts[0].Caption)); - responseDocument.Included[1].Attributes.ShouldContainKey("url").With(value => value.Should().Be(blog.Owner.Posts[0].Url)); + responseDocument.Included[1].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(blog.Owner.Posts[0].Caption); + responseDocument.Included[1].Attributes.Should().ContainKey("url").WhoseValue.Should().Be(blog.Owner.Posts[0].Url); - responseDocument.Included[1].Relationships.ShouldContainKey("labels").With(value => + responseDocument.Included[1].Relationships.Should().ContainKey("labels").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which; @@ -650,10 +650,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); + responseDocument.Data.ManyValue[0].Attributes.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -686,7 +686,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(post.StringId); responseDocument.Data.ManyValue[0].Attributes.Should().BeNull(); responseDocument.Data.ManyValue[0].Relationships.Should().BeNull(); @@ -709,13 +709,13 @@ public async Task Cannot_select_on_unknown_resource_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist. {parameterName}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName.Text); } @@ -734,13 +734,13 @@ public async Task Cannot_select_attribute_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"Retrieving the attribute 'password' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("fields[webAccounts]"); } @@ -759,13 +759,13 @@ public async Task Cannot_select_ToOne_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"Retrieving the relationship 'person' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("fields[webAccounts]"); } @@ -784,13 +784,13 @@ public async Task Cannot_select_ToMany_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"Retrieving the relationship 'appointments' is not allowed. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("fields[calendars]"); } @@ -818,10 +818,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("showAdvertisements").With(value => value.Should().Be(blog.ShowAdvertisements)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("showAdvertisements").WhoseValue.Should().Be(blog.ShowAdvertisements); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); var blogCaptured = (Blog)store.Resources.Should().ContainSingle(resource => resource is Blog).Which; @@ -853,20 +853,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(post.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(2); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("caption").With(value => value.Should().Be(post.Caption)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("url").With(value => value.Should().Be(post.Url)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(2); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("caption").WhoseValue.Should().Be(post.Caption); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("url").WhoseValue.Should().Be(post.Url); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("author").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("author").WhoseValue.With(value => { - value.ShouldNotBeNull(); + value.Should().NotBeNull(); value.Data.Value.Should().BeNull(); - value.Links.ShouldNotBeNull(); - value.Links.Self.ShouldNotBeNull(); - value.Links.Related.ShouldNotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().NotBeNull(); + value.Links.Related.Should().NotBeNull(); }); var postCaptured = (BlogPost)store.Resources.Should().ContainSingle(resource => resource is BlogPost).Which; @@ -896,11 +896,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(account.StringId); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); - responseDocument.Included.ShouldHaveCount(2); - responseDocument.Included.Should().OnlyContain(resourceObject => resourceObject.Type == "blogPosts"); + responseDocument.Included.Should().HaveCount(2); + responseDocument.Included.Should().OnlyContain(resource => resource.Type == "blogPosts"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs index f3aa021389..de1623fb12 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs @@ -57,15 +57,15 @@ public async Task Sets_location_header_for_created_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - string newWorkItemId = responseDocument.Data.SingleValue.ShouldNotBeNull().Id.ShouldNotBeNull(); + string newWorkItemId = responseDocument.Data.SingleValue.RefShould().NotBeNull().And.Subject.Id.Should().NotBeNull().And.Subject; httpResponse.Headers.Location.Should().Be($"http://localhost/workItems/{newWorkItemId}"); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be("http://localhost/workItems/"); responseDocument.Links.First.Should().BeNull(); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"{httpResponse.Headers.Location}"); } @@ -96,13 +96,13 @@ public async Task Can_create_resource_with_int_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newWorkItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(newWorkItem.DueAt)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newWorkItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(newWorkItem.DueAt); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -113,7 +113,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(WorkItem).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -144,13 +144,13 @@ public async Task Can_create_resource_with_long_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("userAccounts"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(newUserAccount.FirstName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(newUserAccount.LastName)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(newUserAccount.FirstName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(newUserAccount.LastName); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - long newUserAccountId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newUserAccountId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -161,7 +161,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(UserAccount).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -191,12 +191,12 @@ public async Task Can_create_resource_with_guid_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItemGroups"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(newGroup.Name)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(newGroup.Name); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + Guid newGroupId = Guid.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -206,7 +206,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -236,13 +236,13 @@ public async Task Can_create_resource_without_attributes_or_relationships() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().BeNull()); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("dueAt").With(value => value.Should().BeNull()); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().BeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().BeNull(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -280,15 +280,15 @@ public async Task Cannot_create_resource_with_unknown_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown attribute found."); error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'workItems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -321,12 +321,12 @@ public async Task Can_create_resource_with_unknown_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newWorkItem.Description)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newWorkItem.Description); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -367,15 +367,15 @@ public async Task Cannot_create_resource_with_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'workItems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -412,18 +412,18 @@ public async Task Can_create_resource_with_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem? workItemInDatabase = await dbContext.WorkItems.FirstWithIdOrDefaultAsync(newWorkItemId); - workItemInDatabase.ShouldNotBeNull(); + workItemInDatabase.Should().NotBeNull(); }); } @@ -452,15 +452,15 @@ public async Task Cannot_create_resource_with_client_generated_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: The use of client-generated IDs is disabled."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -477,10 +477,10 @@ public async Task Cannot_create_resource_for_missing_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -504,14 +504,14 @@ public async Task Cannot_create_resource_for_null_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -534,14 +534,14 @@ public async Task Cannot_create_resource_for_missing_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -561,15 +561,15 @@ public async Task Cannot_create_resource_for_null_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -595,15 +595,15 @@ public async Task Cannot_create_resource_for_array_data() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -628,15 +628,15 @@ public async Task Cannot_create_resource_for_missing_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -662,15 +662,15 @@ public async Task Cannot_create_resource_for_unknown_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -720,15 +720,15 @@ public async Task Cannot_create_on_resource_type_mismatch_between_url_and_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'workItems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -755,15 +755,15 @@ public async Task Cannot_create_resource_with_readonly_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute is read-only."); error.Detail.Should().Be("Attribute 'isDeprecated' on resource type 'workItemGroups' is read-only."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isDeprecated"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -780,14 +780,14 @@ public async Task Cannot_create_resource_for_broken_JSON_request_body() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().StartWith("'{' is invalid after a property name."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -814,15 +814,15 @@ public async Task Cannot_create_resource_with_incompatible_attribute_value() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible attribute value found."); error.Detail.Should().Be("Failed to convert attribute 'dueAt' with value 'not-a-valid-time' of type 'String' to type 'Nullable'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/dueAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -894,11 +894,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newDescription)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newDescription); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -916,13 +916,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => workItemInDatabase.Description.Should().Be(newDescription); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccounts[0].Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingUserAccounts[1].Id); - workItemInDatabase.Tags.ShouldHaveCount(1); + workItemInDatabase.Tags.Should().HaveCount(1); workItemInDatabase.Tags.Single().Id.Should().Be(existingTag.Id); }); } @@ -951,14 +951,14 @@ public async Task Cannot_assign_attribute_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute value cannot be assigned when creating resource."); error.Detail.Should().Be("The attribute 'isImportant' on resource type 'workItems' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isImportant"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs index d4cd2afa1d..5d8e5041c9 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs @@ -65,11 +65,11 @@ public async Task Can_create_resource_with_client_generated_guid_ID_having_side_ string groupName = $"{newGroup.Name}{ImplicitlyChangingWorkItemGroupDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItemGroups"); responseDocument.Data.SingleValue.Id.Should().Be(newGroup.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(groupName)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(groupName); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -79,7 +79,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -118,11 +118,11 @@ public async Task Can_create_resource_with_client_generated_guid_ID_having_side_ string groupName = $"{newGroup.Name}{ImplicitlyChangingWorkItemGroupDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItemGroups"); responseDocument.Data.SingleValue.Id.Should().Be(newGroup.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(groupName)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(groupName); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -133,7 +133,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -184,7 +184,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -235,7 +235,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -277,11 +277,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => const string defaultId = AssignIdToRgbColorDefinition.DefaultId; const string defaultName = AssignIdToRgbColorDefinition.DefaultName; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("rgbColors"); responseDocument.Data.SingleValue.Id.Should().Be(defaultId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("displayName").With(value => value.Should().Be(defaultName)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("displayName").WhoseValue.Should().Be(defaultName); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -330,15 +330,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -373,15 +373,15 @@ public async Task Cannot_create_resource_with_client_generated_zero_guid_ID(Clie // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is invalid."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -416,15 +416,15 @@ public async Task Cannot_create_resource_with_client_generated_empty_guid_ID(Cli // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is invalid."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -474,7 +474,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -511,15 +511,15 @@ public async Task Cannot_create_resource_with_client_generated_zero_long_ID(Clie // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is invalid."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -555,15 +555,15 @@ public async Task Cannot_create_resource_with_client_generated_empty_long_ID(Cli // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is invalid."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Theory] @@ -608,7 +608,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs index 8a83a14884..ef2c3ee216 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs @@ -68,18 +68,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); responseDocument.Included.Should().BeNull(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Subscribers.ShouldHaveCount(2); + workItemInDatabase.Subscribers.Should().HaveCount(2); workItemInDatabase.Subscribers.Should().ContainSingle(subscriber => subscriber.Id == existingUserAccounts[0].Id); workItemInDatabase.Subscribers.Should().ContainSingle(subscriber => subscriber.Id == existingUserAccounts[1].Id); }); @@ -132,25 +132,25 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().OnlyContain(resource => resource.Type == "userAccounts"); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingUserAccounts[0].StringId); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingUserAccounts[1].StringId); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldContainKey("firstName") != null); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldContainKey("lastName") != null); - responseDocument.Included.Should().OnlyContain(resource => resource.Relationships.ShouldNotBeNull().Count > 0); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("firstName").WhoseValue != null); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("lastName").WhoseValue != null); + responseDocument.Included.Should().OnlyContain(resource => resource.Relationships != null && resource.Relationships.Count > 0); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Subscribers.ShouldHaveCount(2); + workItemInDatabase.Subscribers.Should().HaveCount(2); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingUserAccounts[0].Id); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingUserAccounts[1].Id); }); @@ -203,25 +203,25 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included.Should().OnlyContain(resource => resource.Type == "userAccounts"); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingUserAccounts[0].StringId); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingUserAccounts[1].StringId); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldNotBeNull().Count == 1); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldContainKey("firstName") != null); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes != null && resource.Attributes.Count == 1); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("firstName").WhoseValue != null); responseDocument.Included.Should().OnlyContain(resource => resource.Relationships == null); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Subscribers.ShouldHaveCount(2); + workItemInDatabase.Subscribers.Should().HaveCount(2); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingUserAccounts[0].Id); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingUserAccounts[1].Id); }); @@ -285,36 +285,36 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(newWorkItem.Priority)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(newWorkItem.Priority); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("tags").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("tags").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(3); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(3); value.Data.ManyValue[0].Id.Should().Be(existingTags[0].StringId); value.Data.ManyValue[1].Id.Should().Be(existingTags[1].StringId); value.Data.ManyValue[2].Id.Should().Be(existingTags[2].StringId); }); - responseDocument.Included.ShouldHaveCount(3); + responseDocument.Included.Should().HaveCount(3); responseDocument.Included.Should().OnlyContain(resource => resource.Type == "workTags"); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingTags[0].StringId); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingTags[1].StringId); responseDocument.Included.Should().ContainSingle(resource => resource.Id == existingTags[2].StringId); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldNotBeNull().Count == 1); - responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.ShouldContainKey("text") != null); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes != null && resource.Attributes.Count == 1); + responseDocument.Included.Should().OnlyContain(resource => resource.Attributes.Should().ContainKey2("text").WhoseValue != null); responseDocument.Included.Should().OnlyContain(resource => resource.Relationships == null); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Tags.ShouldHaveCount(3); + workItemInDatabase.Tags.Should().HaveCount(3); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[0].Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[1].Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[2].Id); @@ -354,15 +354,15 @@ public async Task Cannot_create_for_missing_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -399,15 +399,15 @@ public async Task Cannot_create_for_unknown_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -443,15 +443,15 @@ public async Task Cannot_create_for_missing_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -503,7 +503,7 @@ public async Task Cannot_create_for_unknown_relationship_IDs() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -552,15 +552,15 @@ public async Task Cannot_create_on_relationship_type_mismatch() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'subscribers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -610,21 +610,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingUserAccount.Id); }); } @@ -655,15 +655,15 @@ public async Task Cannot_create_with_missing_data_in_OneToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -693,15 +693,15 @@ public async Task Cannot_create_with_null_data_in_ManyToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -733,15 +733,15 @@ public async Task Cannot_create_with_object_data_in_ManyToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -781,15 +781,15 @@ public async Task Cannot_create_resource_with_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'lid' element is not supported at this endpoint."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/lid"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -826,14 +826,14 @@ public async Task Cannot_assign_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/items"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs index 88989016b1..362e9ec958 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs @@ -74,11 +74,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - string newGroupId = responseDocument.Data.SingleValue.Id.ShouldNotBeNull(); + string newGroupId = responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject; await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WorkItemGroup newGroupInDatabase = groupsInDatabase.Single(group => group.StringId == newGroupId); newGroupInDatabase.Name.Should().Be(newGroupName); - newGroupInDatabase.Color.ShouldNotBeNull(); + newGroupInDatabase.Color.Should().NotBeNull(); newGroupInDatabase.Color.Id.Should().Be(existingGroup.Color.Id); WorkItemGroup existingGroupInDatabase = groupsInDatabase.Single(group => group.Id == existingGroup.Id); @@ -150,11 +150,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RgbColor newColorInDatabase = colorsInDatabase.Single(color => color.Id == newColorId); newColorInDatabase.DisplayName.Should().Be(newDisplayName); - newColorInDatabase.Group.ShouldNotBeNull(); + newColorInDatabase.Group.Should().NotBeNull(); newColorInDatabase.Group.Id.Should().Be(existingColor.Group.Id); RgbColor? existingColorInDatabase = colorsInDatabase.SingleOrDefault(color => color.Id == existingColor.Id); - existingColorInDatabase.ShouldNotBeNull(); + existingColorInDatabase.Should().NotBeNull(); existingColorInDatabase.Group.Should().BeNull(); }); } @@ -198,24 +198,24 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(existingUserAccount.FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccount.LastName)); - responseDocument.Included[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(existingUserAccount.FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccount.LastName); + responseDocument.Included[0].Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccount.Id); }); } @@ -265,26 +265,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(newWorkItem.Description)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(newWorkItem.Description); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("assignee").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("assignee").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Id.Should().Be(existingUserAccount.StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(existingUserAccount.FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccount.LastName)); - responseDocument.Included[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(existingUserAccount.FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccount.LastName); + responseDocument.Included[0].Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -292,7 +292,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => workItemInDatabase.Description.Should().Be(newWorkItem.Description); workItemInDatabase.Priority.Should().Be(newWorkItem.Priority); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccount.Id); }); } @@ -329,15 +329,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -374,15 +374,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -427,15 +427,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -468,15 +468,15 @@ public async Task Cannot_create_for_missing_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -510,15 +510,15 @@ public async Task Cannot_create_for_unknown_relationship_type() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -551,15 +551,15 @@ public async Task Cannot_create_for_missing_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -595,7 +595,7 @@ public async Task Cannot_create_with_unknown_relationship_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -636,15 +636,15 @@ public async Task Cannot_create_on_relationship_type_mismatch() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -696,24 +696,24 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccounts[1].StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(existingUserAccounts[1].FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccounts[1].LastName)); - responseDocument.Included[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(existingUserAccounts[1].FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccounts[1].LastName); + responseDocument.Included[0].Relationships.Should().NotBeEmpty(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccounts[1].Id); }); } @@ -752,15 +752,15 @@ public async Task Cannot_create_resource_with_local_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'lid' element is not supported at this endpoint."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/lid"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -794,14 +794,14 @@ public async Task Cannot_assign_relationship_with_blocked_capability() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/group"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Deleting/DeleteResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Deleting/DeleteResourceTests.cs index de1d1c3ca8..55f870e6d2 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Deleting/DeleteResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Deleting/DeleteResourceTests.cs @@ -65,7 +65,7 @@ public async Task Cannot_delete_unknown_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -141,7 +141,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => RgbColor? colorInDatabase = await dbContext.RgbColors.FirstWithIdOrDefaultAsync(existingGroup.Color.Id); - colorInDatabase.ShouldNotBeNull(); + colorInDatabase.Should().NotBeNull(); colorInDatabase.Group.Should().BeNull(); }); } @@ -213,7 +213,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WorkTag? tagInDatabase = await dbContext.WorkTags.FirstWithIdOrDefaultAsync(existingWorkItem.Tags.ElementAt(0).Id); - tagInDatabase.ShouldNotBeNull(); + tagInDatabase.Should().NotBeNull(); }); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchRelationshipTests.cs index 711e08d004..96f3d9a439 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchRelationshipTests.cs @@ -39,7 +39,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("userAccounts"); responseDocument.Data.SingleValue.Id.Should().Be(workItem.Assignee.StringId); responseDocument.Data.SingleValue.Attributes.Should().BeNull(); @@ -89,7 +89,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); ResourceObject item1 = responseDocument.Data.ManyValue.Single(resource => resource.Id == userAccount.AssignedItems.ElementAt(0).StringId); item1.Type.Should().Be("workItems"); @@ -146,7 +146,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); ResourceObject item1 = responseDocument.Data.ManyValue.Single(resource => resource.Id == workItem.Tags.ElementAt(0).StringId); item1.Type.Should().Be("workTags"); @@ -209,7 +209,7 @@ public async Task Cannot_get_relationship_for_unknown_primary_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -236,7 +236,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -263,7 +263,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchResourceTests.cs index 9aeeb8eb29..77ec9acbbb 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Fetching/FetchResourceTests.cs @@ -41,21 +41,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); ResourceObject item1 = responseDocument.Data.ManyValue.Single(resource => resource.Id == workItems[0].StringId); item1.Type.Should().Be("workItems"); - item1.Attributes.ShouldContainKey("description").With(value => value.Should().Be(workItems[0].Description)); - item1.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(workItems[0].DueAt)); - item1.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(workItems[0].Priority)); - item1.Relationships.ShouldNotBeEmpty(); + item1.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(workItems[0].Description); + item1.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(workItems[0].DueAt); + item1.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(workItems[0].Priority); + item1.Relationships.Should().NotBeEmpty(); ResourceObject item2 = responseDocument.Data.ManyValue.Single(resource => resource.Id == workItems[1].StringId); item2.Type.Should().Be("workItems"); - item2.Attributes.ShouldContainKey("description").With(value => value.Should().Be(workItems[1].Description)); - item2.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(workItems[1].DueAt)); - item2.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(workItems[1].Priority)); - item2.Relationships.ShouldNotBeEmpty(); + item2.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(workItems[1].Description); + item2.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(workItems[1].DueAt); + item2.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(workItems[1].Priority); + item2.Relationships.Should().NotBeEmpty(); } [Fact] @@ -93,13 +93,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(workItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(workItem.Description)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(workItem.DueAt)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(workItem.Priority)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(workItem.Description); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(workItem.DueAt); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(workItem.Priority); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); } [Fact] @@ -131,7 +131,7 @@ public async Task Cannot_get_primary_resource_for_unknown_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -160,12 +160,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("userAccounts"); responseDocument.Data.SingleValue.Id.Should().Be(workItem.Assignee.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(workItem.Assignee.FirstName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(workItem.Assignee.LastName)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(workItem.Assignee.FirstName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(workItem.Assignee.LastName); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); } [Fact] @@ -212,21 +212,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); ResourceObject item1 = responseDocument.Data.ManyValue.Single(resource => resource.Id == userAccount.AssignedItems.ElementAt(0).StringId); item1.Type.Should().Be("workItems"); - item1.Attributes.ShouldContainKey("description").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(0).Description)); - item1.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(0).DueAt)); - item1.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(0).Priority)); - item1.Relationships.ShouldNotBeEmpty(); + item1.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(0).Description); + item1.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(0).DueAt); + item1.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(0).Priority); + item1.Relationships.Should().NotBeEmpty(); ResourceObject item2 = responseDocument.Data.ManyValue.Single(resource => resource.Id == userAccount.AssignedItems.ElementAt(1).StringId); item2.Type.Should().Be("workItems"); - item2.Attributes.ShouldContainKey("description").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(1).Description)); - item2.Attributes.ShouldContainKey("dueAt").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(1).DueAt)); - item2.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(userAccount.AssignedItems.ElementAt(1).Priority)); - item2.Relationships.ShouldNotBeEmpty(); + item2.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(1).Description); + item2.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(1).DueAt); + item2.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(userAccount.AssignedItems.ElementAt(1).Priority); + item2.Relationships.Should().NotBeEmpty(); } [Fact] @@ -273,19 +273,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); ResourceObject item1 = responseDocument.Data.ManyValue.Single(resource => resource.Id == workItem.Tags.ElementAt(0).StringId); item1.Type.Should().Be("workTags"); - item1.Attributes.ShouldContainKey("text").With(value => value.Should().Be(workItem.Tags.ElementAt(0).Text)); - item1.Attributes.ShouldContainKey("isBuiltIn").With(value => value.Should().Be(workItem.Tags.ElementAt(0).IsBuiltIn)); - item1.Relationships.ShouldNotBeEmpty(); + item1.Attributes.Should().ContainKey("text").WhoseValue.Should().Be(workItem.Tags.ElementAt(0).Text); + item1.Attributes.Should().ContainKey("isBuiltIn").WhoseValue.Should().Be(workItem.Tags.ElementAt(0).IsBuiltIn); + item1.Relationships.Should().NotBeEmpty(); ResourceObject item2 = responseDocument.Data.ManyValue.Single(resource => resource.Id == workItem.Tags.ElementAt(1).StringId); item2.Type.Should().Be("workTags"); - item2.Attributes.ShouldContainKey("text").With(value => value.Should().Be(workItem.Tags.ElementAt(1).Text)); - item2.Attributes.ShouldContainKey("isBuiltIn").With(value => value.Should().Be(workItem.Tags.ElementAt(1).IsBuiltIn)); - item2.Relationships.ShouldNotBeEmpty(); + item2.Attributes.Should().ContainKey("text").WhoseValue.Should().Be(workItem.Tags.ElementAt(1).Text); + item2.Attributes.Should().ContainKey("isBuiltIn").WhoseValue.Should().Be(workItem.Tags.ElementAt(1).IsBuiltIn); + item2.Relationships.Should().NotBeEmpty(); } [Fact] @@ -340,7 +340,7 @@ public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -369,7 +369,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -397,7 +397,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs index 250729c31d..e2f3c8933b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs @@ -51,14 +51,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this endpoint."); error.Detail.Should().Be("Relationship 'assignee' is not a to-many relationship."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -107,7 +107,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(3); + workItemInDatabase.Subscribers.Should().HaveCount(3); workItemInDatabase.Subscribers.Should().ContainSingle(subscriber => subscriber.Id == existingWorkItem.Subscribers.ElementAt(0).Id); workItemInDatabase.Subscribers.Should().ContainSingle(subscriber => subscriber.Id == existingWorkItem.Subscribers.ElementAt(1).Id); workItemInDatabase.Subscribers.Should().ContainSingle(subscriber => subscriber.Id == existingSubscriber.Id); @@ -164,13 +164,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => int tagId1 = existingWorkItems[0].Tags.ElementAt(0).Id; int tagId2 = existingWorkItems[1].Tags.ElementAt(0).Id; - workItemInDatabase1.Tags.ShouldHaveCount(2); + workItemInDatabase1.Tags.Should().HaveCount(2); workItemInDatabase1.Tags.Should().ContainSingle(workTag => workTag.Id == tagId1); workItemInDatabase1.Tags.Should().ContainSingle(workTag => workTag.Id == tagId2); WorkItem workItemInDatabase2 = workItemsInDatabase.Single(workItem => workItem.Id == existingWorkItems[1].Id); - workItemInDatabase2.Tags.ShouldHaveCount(1); + workItemInDatabase2.Tags.Should().HaveCount(1); workItemInDatabase2.Tags.ElementAt(0).Id.Should().Be(tagId2); }); } @@ -197,10 +197,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -232,14 +232,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -273,15 +273,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -316,15 +316,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -358,15 +358,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -409,7 +409,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -464,7 +464,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -549,7 +549,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -591,7 +591,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -633,7 +633,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -676,15 +676,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -731,7 +731,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingSubscriber.Id); }); } @@ -767,7 +767,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(0); + workItemInDatabase.Subscribers.Should().HaveCount(0); }); } @@ -795,14 +795,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -830,15 +830,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -868,15 +868,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -918,7 +918,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Children).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Children.ShouldHaveCount(2); + workItemInDatabase.Children.Should().HaveCount(2); workItemInDatabase.Children.Should().ContainSingle(workItem => workItem.Id == existingWorkItem.Children[0].Id); workItemInDatabase.Children.Should().ContainSingle(workItem => workItem.Id == existingWorkItem.Id); }); @@ -972,10 +972,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - workItemInDatabase.RelatedFrom.ShouldHaveCount(1); + workItemInDatabase.RelatedFrom.Should().HaveCount(1); workItemInDatabase.RelatedFrom.Should().OnlyContain(workItem => workItem.Id == existingWorkItem.Id); - workItemInDatabase.RelatedTo.ShouldHaveCount(2); + workItemInDatabase.RelatedTo.Should().HaveCount(2); workItemInDatabase.RelatedTo.Should().ContainSingle(workItem => workItem.Id == existingWorkItem.Id); workItemInDatabase.RelatedTo.Should().ContainSingle(workItem => workItem.Id == existingWorkItem.RelatedTo[0].Id); }); @@ -1013,13 +1013,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be added to."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be added to."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs index 612e9df143..c9b948ca34 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs @@ -62,14 +62,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this endpoint."); error.Detail.Should().Be("Relationship 'assignee' is not a to-many relationship."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -118,11 +118,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingWorkItem.Subscribers.ElementAt(1).Id); List userAccountsInDatabase = await dbContext.UserAccounts.ToListAsync(); - userAccountsInDatabase.ShouldHaveCount(3); + userAccountsInDatabase.Should().HaveCount(3); }); } @@ -165,17 +165,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Should().BeEmpty(); - workItemDefinition.PreloadedSubscribers.ShouldHaveCount(1); + workItemDefinition.PreloadedSubscribers.Should().HaveCount(1); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingWorkItem.Subscribers.ElementAt(1).Id); List userAccountsInDatabase = await dbContext.UserAccounts.ToListAsync(); - userAccountsInDatabase.ShouldHaveCount(3); + userAccountsInDatabase.Should().HaveCount(3); }); } @@ -226,11 +226,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Tags.ShouldHaveCount(1); + workItemInDatabase.Tags.Should().HaveCount(1); workItemInDatabase.Tags.Single().Id.Should().Be(existingWorkItem.Tags.ElementAt(0).Id); List tagsInDatabase = await dbContext.WorkTags.ToListAsync(); - tagsInDatabase.ShouldHaveCount(3); + tagsInDatabase.Should().HaveCount(3); }); } @@ -273,17 +273,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Should().BeEmpty(); - workItemDefinition.PreloadedTags.ShouldHaveCount(1); + workItemDefinition.PreloadedTags.Should().HaveCount(1); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Tags.ShouldHaveCount(1); + workItemInDatabase.Tags.Should().HaveCount(1); workItemInDatabase.Tags.Single().Id.Should().Be(existingWorkItem.Tags.ElementAt(0).Id); List tagsInDatabase = await dbContext.WorkTags.ToListAsync(); - tagsInDatabase.ShouldHaveCount(3); + tagsInDatabase.Should().HaveCount(3); }); } @@ -309,10 +309,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -344,14 +344,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -386,15 +386,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -429,15 +429,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -471,15 +471,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -522,7 +522,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -577,7 +577,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -662,7 +662,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -704,7 +704,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -746,7 +746,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -789,15 +789,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -844,7 +844,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingWorkItem.Subscribers.ElementAt(1).Id); }); } @@ -881,7 +881,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingWorkItem.Subscribers.ElementAt(0).Id); }); } @@ -910,14 +910,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -945,15 +945,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -983,15 +983,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1036,7 +1036,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Children).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Children.ShouldHaveCount(1); + workItemInDatabase.Children.Should().HaveCount(1); workItemInDatabase.Children[0].Id.Should().Be(existingWorkItem.Children[0].Id); }); } @@ -1092,7 +1092,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - workItemInDatabase.RelatedFrom.ShouldHaveCount(1); + workItemInDatabase.RelatedFrom.Should().HaveCount(1); workItemInDatabase.RelatedFrom[0].Id.Should().Be(existingWorkItem.RelatedFrom[0].Id); workItemInDatabase.RelatedTo.Should().BeEmpty(); @@ -1131,14 +1131,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be removed from."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be removed from."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs index 3e998a12e8..7a8c0cfea1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs @@ -139,7 +139,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(2); + workItemInDatabase.Subscribers.Should().HaveCount(2); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingWorkItem.Subscribers.ElementAt(1).Id); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingSubscriber.Id); }); @@ -197,7 +197,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Tags.ShouldHaveCount(3); + workItemInDatabase.Tags.Should().HaveCount(3); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingWorkItem.Tags.ElementAt(0).Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[0].Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[1].Id); @@ -226,10 +226,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -261,14 +261,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -302,15 +302,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -345,15 +345,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -387,15 +387,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -438,7 +438,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -495,7 +495,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -575,7 +575,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -617,7 +617,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -659,7 +659,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -702,15 +702,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -759,7 +759,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingSubscriber.Id); }); } @@ -788,14 +788,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -823,15 +823,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -861,15 +861,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1000,7 +1000,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Children).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Children.ShouldHaveCount(1); + workItemInDatabase.Children.Should().HaveCount(1); workItemInDatabase.Children[0].Id.Should().Be(existingWorkItem.Id); }); } @@ -1052,10 +1052,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - workItemInDatabase.RelatedFrom.ShouldHaveCount(1); + workItemInDatabase.RelatedFrom.Should().HaveCount(1); workItemInDatabase.RelatedFrom[0].Id.Should().Be(existingWorkItem.Id); - workItemInDatabase.RelatedTo.ShouldHaveCount(1); + workItemInDatabase.RelatedTo.Should().HaveCount(1); workItemInDatabase.RelatedTo[0].Id.Should().Be(existingWorkItem.Id); }); } @@ -1092,13 +1092,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs index 573489425e..e05fda291f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs @@ -136,7 +136,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => colorInDatabase1.Group.Should().BeNull(); RgbColor colorInDatabase2 = colorsInDatabase.Single(color => color.Id == existingColor.Id); - colorInDatabase2.Group.ShouldNotBeNull(); + colorInDatabase2.Group.Should().NotBeNull(); colorInDatabase2.Group.Id.Should().Be(existingGroup.Id); }); } @@ -182,17 +182,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => groupInDatabase1.Color.Should().BeNull(); WorkItemGroup groupInDatabase2 = groupsInDatabase.Single(group => group.Id == existingGroups[1].Id); - groupInDatabase2.Color.ShouldNotBeNull(); + groupInDatabase2.Color.Should().NotBeNull(); groupInDatabase2.Color.Id.Should().Be(existingGroups[0].Color!.Id); List colorsInDatabase = await dbContext.RgbColors.Include(color => color.Group).ToListAsync(); RgbColor colorInDatabase1 = colorsInDatabase.Single(color => color.Id == existingGroups[0].Color!.Id); - colorInDatabase1.Group.ShouldNotBeNull(); + colorInDatabase1.Group.Should().NotBeNull(); colorInDatabase1.Group.Id.Should().Be(existingGroups[1].Id); RgbColor? colorInDatabase2 = colorsInDatabase.SingleOrDefault(color => color.Id == existingGroups[1].Color!.Id); - colorInDatabase2.ShouldNotBeNull(); + colorInDatabase2.Should().NotBeNull(); colorInDatabase2.Group.Should().BeNull(); }); } @@ -235,7 +235,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WorkItem workItemInDatabase2 = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(workItemId); - workItemInDatabase2.Assignee.ShouldNotBeNull(); + workItemInDatabase2.Assignee.Should().NotBeNull(); workItemInDatabase2.Assignee.Id.Should().Be(existingUserAccounts[1].Id); }); } @@ -262,10 +262,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -297,14 +297,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -332,14 +332,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -375,15 +375,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -414,15 +414,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -454,15 +454,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -493,15 +493,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -535,7 +535,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -609,7 +609,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -648,7 +648,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -687,7 +687,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -727,15 +727,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -812,7 +812,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Parent).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Parent.ShouldNotBeNull(); + workItemInDatabase.Parent.Should().NotBeNull(); workItemInDatabase.Parent.Id.Should().Be(existingWorkItem.Id); }); } @@ -846,13 +846,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs index d982f48482..da33ab6dc5 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs @@ -61,7 +61,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -108,7 +108,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -169,13 +169,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(2); + workItemInDatabase.Subscribers.Should().HaveCount(2); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingWorkItem.Subscribers.ElementAt(1).Id); workItemInDatabase.Subscribers.Should().ContainSingle(userAccount => userAccount.Id == existingSubscriber.Id); }); @@ -238,13 +238,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Tags.ShouldHaveCount(3); + workItemInDatabase.Tags.Should().HaveCount(3); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingWorkItem.Tags.ElementAt(0).Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[0].Id); workItemInDatabase.Tags.Should().ContainSingle(workTag => workTag.Id == existingTags[1].Id); @@ -295,24 +295,24 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingWorkItem.Priority)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingWorkItem.Priority); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(existingUserAccount.FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccount.LastName)); - responseDocument.Included[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(existingUserAccount.FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccount.LastName); + responseDocument.Included[0].Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingUserAccount.Id); }); } @@ -361,34 +361,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingWorkItem.Priority)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingWorkItem.Priority); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("tags").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("tags").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(existingTag.StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("workTags"); responseDocument.Included[0].Id.Should().Be(existingTag.StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("text").With(value => value.Should().Be(existingTag.Text)); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("text").WhoseValue.Should().Be(existingTag.Text); responseDocument.Included[0].Relationships.Should().BeNull(); - int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newWorkItemId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Tags).FirstWithIdAsync(newWorkItemId); - workItemInDatabase.Tags.ShouldHaveCount(1); + workItemInDatabase.Tags.Should().HaveCount(1); workItemInDatabase.Tags.Single().Id.Should().Be(existingTag.Id); }); } @@ -435,15 +435,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -489,15 +489,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -542,15 +542,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -623,7 +623,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(4); + responseDocument.Errors.Should().HaveCount(4); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -689,15 +689,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'subscribers'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -751,13 +751,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Subscribers).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingSubscriber.Id); }); } @@ -797,15 +797,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -844,15 +844,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -893,15 +893,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an array, instead of an object."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -943,7 +943,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -992,7 +992,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1055,13 +1055,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Children).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Children.ShouldHaveCount(1); + workItemInDatabase.Children.Should().HaveCount(1); workItemInDatabase.Children[0].Id.Should().Be(existingWorkItem.Id); }); } @@ -1109,7 +1109,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1124,10 +1124,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - workItemInDatabase.RelatedFrom.ShouldHaveCount(1); + workItemInDatabase.RelatedFrom.Should().HaveCount(1); workItemInDatabase.RelatedFrom[0].Id.Should().Be(existingWorkItem.Id); - workItemInDatabase.RelatedTo.ShouldHaveCount(1); + workItemInDatabase.RelatedTo.Should().HaveCount(1); workItemInDatabase.RelatedTo[0].Id.Should().Be(existingWorkItem.Id); }); } @@ -1175,14 +1175,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/items"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs index efd498c53c..ee43e42a0d 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs @@ -117,15 +117,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown attribute found."); error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'userAccounts'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -217,15 +217,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown relationship found."); error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'userAccounts'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/doesNotExist"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -310,12 +310,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string groupName = $"{newName}{ImplicitlyChangingWorkItemGroupDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItemGroups"); responseDocument.Data.SingleValue.Id.Should().Be(existingGroup.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(groupName)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isPublic").With(value => value.Should().Be(existingGroup.IsPublic)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(groupName); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isPublic").WhoseValue.Should().Be(existingGroup.IsPublic); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -326,7 +326,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(WorkItemGroup).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -374,7 +374,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); PropertyInfo? property = typeof(RgbColor).GetProperty(nameof(Identifiable.Id)); - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.PropertyType.Should().Be(); } @@ -461,14 +461,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string itemDescription = $"{newDescription}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(itemDescription)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("dueAt").With(value => value.Should().BeNull()); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingWorkItem.Priority)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isImportant").With(value => value.Should().Be(existingWorkItem.IsImportant)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(itemDescription); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("dueAt").WhoseValue.Should().BeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingWorkItem.Priority); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isImportant").WhoseValue.Should().Be(existingWorkItem.IsImportant); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -517,12 +517,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string itemDescription = $"{newDescription}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(2); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(itemDescription)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingWorkItem.Priority)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(2); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(itemDescription); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingWorkItem.Priority); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -574,26 +574,26 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string itemDescription = $"{newDescription}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(2); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(itemDescription)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("priority").With(value => value.Should().Be(existingWorkItem.Priority)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(2); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(itemDescription); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(existingWorkItem.Priority); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("tags").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("tags").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.ManyValue.ShouldHaveCount(1); + value.Should().NotBeNull(); + value.Data.ManyValue.Should().HaveCount(1); value.Data.ManyValue[0].Id.Should().Be(existingWorkItem.Tags.Single().StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("workTags"); responseDocument.Included[0].Id.Should().Be(existingWorkItem.Tags.Single().StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("text").With(value => value.Should().Be(existingWorkItem.Tags.Single().Text)); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("text").WhoseValue.Should().Be(existingWorkItem.Tags.Single().Text); responseDocument.Included[0].Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -636,9 +636,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.Values.Should().OnlyContain(value => value.ShouldNotBeNull().Data.Value == null); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Values.Should().OnlyContain(value => value != null && value.Data.Value == null); responseDocument.Included.Should().BeNull(); } @@ -664,10 +664,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - httpResponse.Content.Headers.ContentType.ShouldNotBeNull(); + httpResponse.Content.Headers.ContentType.Should().NotBeNull(); httpResponse.Content.Headers.ContentType.ToString().Should().Be(JsonApiMediaType.Default.ToString()); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -699,14 +699,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -737,14 +737,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -772,15 +772,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -815,15 +815,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -854,15 +854,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -894,15 +894,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -933,15 +933,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -999,7 +999,7 @@ public async Task Cannot_update_resource_on_unknown_resource_ID_in_url() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1038,15 +1038,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'workItems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1078,15 +1078,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Conflicting 'id' values found."); error.Detail.Should().Be($"Expected '{existingWorkItems[1].StringId}' instead of '{existingWorkItems[0].StringId}'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1122,15 +1122,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute is read-only."); error.Detail.Should().Be("Attribute 'isDeprecated' on resource type 'workItemGroups' is read-only."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isDeprecated"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1155,14 +1155,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().StartWith("Expected end of string, but instead reached end of data."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1198,15 +1198,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Resource ID is read-only."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/id"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1241,14 +1241,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().Be($"Failed to convert ID '{existingWorkItem.Id}' of type 'Number' to type 'String'."); error.Source.Should().BeNull(); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1288,15 +1288,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Incompatible attribute value found."); error.Detail.Should().Match("Failed to convert attribute 'dueAt' with value '*start*end*' of type 'Object' to type 'Nullable'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/dueAt"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -1376,9 +1376,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string itemDescription = $"{newDescription}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(itemDescription)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(itemDescription); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1396,13 +1396,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => workItemInDatabase.Description.Should().Be(itemDescription); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccounts[0].Id); - workItemInDatabase.Subscribers.ShouldHaveCount(1); + workItemInDatabase.Subscribers.Should().HaveCount(1); workItemInDatabase.Subscribers.Single().Id.Should().Be(existingUserAccounts[1].Id); - workItemInDatabase.Tags.ShouldHaveCount(1); + workItemInDatabase.Tags.Should().HaveCount(1); workItemInDatabase.Tags.Single().Id.Should().Be(existingTag.Id); }); } @@ -1472,7 +1472,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -1489,16 +1489,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - workItemInDatabase.Parent.ShouldNotBeNull(); + workItemInDatabase.Parent.Should().NotBeNull(); workItemInDatabase.Parent.Id.Should().Be(existingWorkItem.Id); - workItemInDatabase.Children.ShouldHaveCount(1); + workItemInDatabase.Children.Should().HaveCount(1); workItemInDatabase.Children.Single().Id.Should().Be(existingWorkItem.Id); - workItemInDatabase.RelatedFrom.ShouldHaveCount(1); + workItemInDatabase.RelatedFrom.Should().HaveCount(1); workItemInDatabase.RelatedFrom.Single().Id.Should().Be(existingWorkItem.Id); - workItemInDatabase.RelatedTo.ShouldHaveCount(1); + workItemInDatabase.RelatedTo.Should().HaveCount(1); workItemInDatabase.RelatedTo.Single().Id.Should().Be(existingWorkItem.Id); }); } @@ -1536,14 +1536,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Attribute value cannot be assigned when updating resource."); error.Detail.Should().Be("The attribute 'isImportant' on resource type 'workItems' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isImportant"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs index f290d4b1bd..bd0cbd1943 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs @@ -62,7 +62,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -125,7 +125,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => colorInDatabase1.Group.Should().BeNull(); RgbColor colorInDatabase2 = colorsInDatabase.Single(color => color.Id == existingColor.Id); - colorInDatabase2.Group.ShouldNotBeNull(); + colorInDatabase2.Group.Should().NotBeNull(); colorInDatabase2.Group.Id.Should().Be(existingGroup.Id); }); } @@ -182,17 +182,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => groupInDatabase1.Color.Should().BeNull(); WorkItemGroup groupInDatabase2 = groupsInDatabase.Single(group => group.Id == existingGroups[1].Id); - groupInDatabase2.Color.ShouldNotBeNull(); + groupInDatabase2.Color.Should().NotBeNull(); groupInDatabase2.Color.Id.Should().Be(existingGroups[0].Color!.Id); List colorsInDatabase = await dbContext.RgbColors.Include(color => color.Group).ToListAsync(); RgbColor colorInDatabase1 = colorsInDatabase.Single(color => color.Id == existingGroups[0].Color!.Id); - colorInDatabase1.Group.ShouldNotBeNull(); + colorInDatabase1.Group.Should().NotBeNull(); colorInDatabase1.Group.Id.Should().Be(existingGroups[1].Id); RgbColor? colorInDatabase2 = colorsInDatabase.SingleOrDefault(color => color.Id == existingGroups[1].Color!.Id); - colorInDatabase2.ShouldNotBeNull(); + colorInDatabase2.Should().NotBeNull(); colorInDatabase2.Group.Should().BeNull(); }); } @@ -285,7 +285,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -293,7 +293,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WorkItem workItemInDatabase2 = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(workItemId); - workItemInDatabase2.Assignee.ShouldNotBeNull(); + workItemInDatabase2.Assignee.Should().NotBeNull(); workItemInDatabase2.Assignee.Id.Should().Be(existingUserAccounts[1].Id); }); } @@ -341,24 +341,24 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string description = $"{existingWorkItem.Description}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(description)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(description); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be(existingUserAccount.FirstName)); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccount.LastName)); - responseDocument.Included[0].Relationships.ShouldNotBeEmpty(); + responseDocument.Included[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be(existingUserAccount.FirstName); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccount.LastName); + responseDocument.Included[0].Relationships.Should().NotBeEmpty(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccount.Id); }); } @@ -408,32 +408,32 @@ await _testContext.RunOnDatabaseAsync(async dbContext => string description = $"{existingWorkItem.Description}{ImplicitlyChangingWorkItemDefinition.Suffix}"; - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("workItems"); responseDocument.Data.SingleValue.Id.Should().Be(existingWorkItem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("description").With(value => value.Should().Be(description)); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("description").WhoseValue.Should().Be(description); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("assignee").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("assignee").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Id.Should().Be(existingUserAccount.StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("userAccounts"); responseDocument.Included[0].Id.Should().Be(existingUserAccount.StringId); - responseDocument.Included[0].Attributes.ShouldHaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("lastName").With(value => value.Should().Be(existingUserAccount.LastName)); + responseDocument.Included[0].Attributes.Should().HaveCount(1); + responseDocument.Included[0].Attributes.Should().ContainKey("lastName").WhoseValue.Should().Be(existingUserAccount.LastName); responseDocument.Included[0].Relationships.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Assignee).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Assignee.ShouldNotBeNull(); + workItemInDatabase.Assignee.Should().NotBeNull(); workItemInDatabase.Assignee.Id.Should().Be(existingUserAccount.Id); }); } @@ -472,15 +472,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -519,15 +519,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -574,15 +574,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Expected an object or 'null', instead of an array."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -624,15 +624,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'type' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -675,15 +675,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -725,15 +725,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -778,7 +778,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -828,15 +828,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } [Fact] @@ -878,7 +878,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -928,13 +928,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => { WorkItem workItemInDatabase = await dbContext.WorkItems.Include(workItem => workItem.Parent).FirstWithIdAsync(existingWorkItem.Id); - workItemInDatabase.Parent.ShouldNotBeNull(); + workItemInDatabase.Parent.Should().NotBeNull(); workItemInDatabase.Parent.Id.Should().Be(existingWorkItem.Id); }); } @@ -979,14 +979,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/group"); - error.Meta.ShouldContainKey("requestBody").With(value => value.ShouldNotBeNull().ToString().ShouldNotBeEmpty()); + error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/RequiredRelationships/DefaultBehaviorTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/RequiredRelationships/DefaultBehaviorTests.cs index 0e3ac0eecf..eab806308e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/RequiredRelationships/DefaultBehaviorTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/RequiredRelationships/DefaultBehaviorTests.cs @@ -53,20 +53,20 @@ public async Task Cannot_create_dependent_side_of_required_ManyToOne_relationshi // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(2); + responseDocument.Errors.Should().HaveCount(2); ErrorObject error1 = responseDocument.Errors[0]; error1.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error1.Title.Should().Be("Input validation failed."); error1.Detail.Should().Be("The Customer field is required."); - error1.Source.ShouldNotBeNull(); + error1.Source.Should().NotBeNull(); error1.Source.Pointer.Should().Be("/data/relationships/customer/data"); ErrorObject error2 = responseDocument.Errors[1]; error2.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error2.Title.Should().Be("Input validation failed."); error2.Detail.Should().Be("The Shipment field is required."); - error2.Source.ShouldNotBeNull(); + error2.Source.Should().NotBeNull(); error2.Source.Pointer.Should().Be("/data/relationships/shipment/data"); } @@ -96,13 +96,13 @@ public async Task Cannot_create_dependent_side_of_required_OneToOne_relationship // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The Order field is required."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/order/data"); } @@ -172,7 +172,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => shipmentInDatabase.Should().BeNull(); Customer? customerInDatabase = await dbContext.Customers.FirstWithIdOrDefaultAsync(existingOrder.Customer.Id); - customerInDatabase.ShouldNotBeNull(); + customerInDatabase.Should().NotBeNull(); }); } @@ -214,13 +214,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Input validation failed."); error.Detail.Should().Be("The Customer field is required."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/customer/data"); } @@ -251,7 +251,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs index 4163a0bade..02fdf3fc1b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceConstructorInjection/ResourceInjectionTests.cs @@ -55,10 +55,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(certificate.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("issueDate").With(value => value.Should().Be(certificate.IssueDate)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("hasExpired").With(value => value.Should().Be(false)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("issueDate").WhoseValue.Should().Be(certificate.IssueDate); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("hasExpired").WhoseValue.Should().Be(false); } [Fact] @@ -85,10 +85,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(postOffices[1].StringId); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("address").With(value => value.Should().Be(postOffices[1].Address)); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("isOpen").With(value => value.Should().Be(true)); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("address").WhoseValue.Should().Be(postOffices[1].Address); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("isOpen").WhoseValue.Should().Be(true); } [Fact] @@ -115,10 +115,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(certificate.Issuer.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isOpen").With(value => value.Should().Be(true)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isOpen").WhoseValue.Should().Be(true); } [Fact] @@ -169,27 +169,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("issueDate").With(value => value.Should().Be(newIssueDate)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("hasExpired").With(value => value.Should().Be(true)); + responseDocument.Data.SingleValue.Should().NotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("issueDate").WhoseValue.Should().Be(newIssueDate); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("hasExpired").WhoseValue.Should().Be(true); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("issuer").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("issuer").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Id.Should().Be(existingOffice.StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].With(resource => { resource.Id.Should().Be(existingOffice.StringId); - resource.Attributes.ShouldContainKey("address").With(value => value.Should().Be(existingOffice.Address)); - resource.Attributes.ShouldContainKey("isOpen").With(value => value.Should().Be(false)); + resource.Attributes.Should().ContainKey("address").WhoseValue.Should().Be(existingOffice.Address); + resource.Attributes.Should().ContainKey("isOpen").WhoseValue.Should().Be(false); }); - int newCertificateId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newCertificateId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -198,7 +198,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => certificateInDatabase.IssueDate.Should().Be(newIssueDate); - certificateInDatabase.Issuer.ShouldNotBeNull(); + certificateInDatabase.Issuer.Should().NotBeNull(); certificateInDatabase.Issuer.Id.Should().Be(existingOffice.Id); }); } @@ -264,7 +264,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => officeInDatabase.Address.Should().Be(newAddress); - officeInDatabase.GiftCertificates.ShouldHaveCount(1); + officeInDatabase.GiftCertificates.Should().HaveCount(1); officeInDatabase.GiftCertificates[0].Id.Should().Be(existingOffice.GiftCertificates[0].Id); }); } @@ -313,7 +313,7 @@ public async Task Cannot_delete_unknown_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -362,7 +362,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { PostOffice officeInDatabase = await dbContext.PostOffices.Include(postOffice => postOffice.GiftCertificates).FirstWithIdAsync(existingOffice.Id); - officeInDatabase.GiftCertificates.ShouldHaveCount(2); + officeInDatabase.GiftCertificates.Should().HaveCount(2); }); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Reading/ResourceDefinitionReadTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Reading/ResourceDefinitionReadTests.cs index a7ff2a2f51..64a298555f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Reading/ResourceDefinitionReadTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Reading/ResourceDefinitionReadTests.cs @@ -67,7 +67,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); @@ -112,20 +112,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("isGivenLightBy").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("isGivenLightBy").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("stars"); value.Data.SingleValue.Id.Should().Be(moon.IsGivenLightBy.StringId); }); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("stars"); responseDocument.Included[0].Id.Should().Be(moon.IsGivenLightBy.StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(moon.IsGivenLightBy.Name)); + responseDocument.Included[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(moon.IsGivenLightBy.Name); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -170,17 +170,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); responseDocument.Included[0].Type.Should().Be("moons"); responseDocument.Included[0].Id.Should().Be(planet.Moons.ElementAt(0).StringId); - responseDocument.Included[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(planet.Moons.ElementAt(0).Name)); + responseDocument.Included[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(planet.Moons.ElementAt(0).Name); responseDocument.Included[1].Type.Should().Be("stars"); responseDocument.Included[1].Id.Should().Be(planet.Moons.ElementAt(0).IsGivenLightBy!.StringId); - responseDocument.Included[1].Attributes.ShouldContainKey("name").With(value => value.Should().Be(planet.Moons.ElementAt(0).IsGivenLightBy!.Name)); + responseDocument.Included[1].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(planet.Moons.ElementAt(0).IsGivenLightBy!.Name); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -233,7 +233,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(planets[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(planets[3].StringId); @@ -289,7 +289,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(planets[3].StringId); responseDocument.Meta.Should().ContainTotal(1); @@ -336,7 +336,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(star.Planets.ElementAt(1).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(star.Planets.ElementAt(3).StringId); @@ -388,7 +388,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(star.Planets.ElementAt(1).StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(star.Planets.ElementAt(3).StringId); @@ -441,7 +441,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be(stars[1].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(stars[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(stars[2].StringId); @@ -493,7 +493,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be(stars[2].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(stars[0].StringId); responseDocument.Data.ManyValue[2].Id.Should().Be(stars[1].StringId); @@ -536,7 +536,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(5); + responseDocument.Data.ManyValue.Should().HaveCount(5); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -577,11 +577,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(star.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(star.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("kind").With(value => value.Should().Be(star.Kind)); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(star.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("kind").WhoseValue.Should().Be(star.Kind); + responseDocument.Data.SingleValue.Relationships.Should().NotBeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -617,11 +617,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(star.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(2); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(star.Name)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("solarRadius").With(value => value.Should().Be(star.SolarRadius)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(2); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(star.Name); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("solarRadius").WhoseValue.Should().Be(star.SolarRadius); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] @@ -658,11 +658,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(star.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(star.Name)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(star.Name); responseDocument.Data.SingleValue.Attributes.Should().NotContainKey("isVisibleFromEarth"); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] { @@ -698,10 +698,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(star.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(1); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("name").With(value => value.Should().Be(star.Name)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("name").WhoseValue.Should().Be(star.Name); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] @@ -745,7 +745,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(moons[1].StringId); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] @@ -802,7 +802,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(moons[2].StringId); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] @@ -843,13 +843,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Custom query string parameters cannot be used on nested resource endpoints."); error.Detail.Should().Be("Query string parameter 'isLargerThanTheSun' cannot be used on a nested resource endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("isLargerThanTheSun"); hitCounter.HitExtensibilityPoints.Should().BeEquivalentTo(new[] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Serialization/ResourceDefinitionSerializationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Serialization/ResourceDefinitionSerializationTests.cs index adb00dbfbf..02d04b03f7 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Serialization/ResourceDefinitionSerializationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceDefinitions/Serialization/ResourceDefinitionSerializationTests.cs @@ -59,19 +59,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(students[0].SocialSecurityNumber); }); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(students[1].SocialSecurityNumber); @@ -110,37 +110,37 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Included.ShouldHaveCount(4); + responseDocument.Included.Should().HaveCount(4); - responseDocument.Included[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarships[0].Participants[0].SocialSecurityNumber); }); - responseDocument.Included[1].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[1].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarships[0].Participants[1].SocialSecurityNumber); }); - responseDocument.Included[2].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[2].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarships[1].Participants[0].SocialSecurityNumber); }); - responseDocument.Included[3].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[3].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarships[1].Participants[1].SocialSecurityNumber); @@ -178,11 +178,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(student.SocialSecurityNumber); @@ -218,19 +218,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarship.Participants[0].SocialSecurityNumber); }); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarship.Participants[1].SocialSecurityNumber); @@ -267,11 +267,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarship.PrimaryContact.SocialSecurityNumber); @@ -307,13 +307,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(scholarship.PrimaryContact.SocialSecurityNumber); @@ -356,17 +356,17 @@ public async Task Decrypts_on_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(newSocialSecurityNumber); }); - int newStudentId = int.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + int newStudentId = int.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -432,13 +432,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); - responseDocument.Included[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(existingStudent.SocialSecurityNumber); @@ -488,11 +488,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(newSocialSecurityNumber); @@ -570,21 +570,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); - responseDocument.Included.ShouldHaveCount(2); + responseDocument.Included.Should().HaveCount(2); - responseDocument.Included[0].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[0].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(existingScholarship.Participants[0].SocialSecurityNumber); }); - responseDocument.Included[1].Attributes.ShouldContainKey("socialSecurityNumber").With(value => + responseDocument.Included[1].Attributes.Should().ContainKey("socialSecurityNumber").WhoseValue.With(value => { - string stringValue = value.Should().BeOfType().Subject.ShouldNotBeNull(); + string stringValue = value.Should().BeOfType().Subject.Should().NotBeNull().And.Subject; string socialSecurityNumber = encryptionService.Decrypt(stringValue); socialSecurityNumber.Should().Be(existingScholarship.Participants[2].SocialSecurityNumber); @@ -620,7 +620,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(scholarship.PrimaryContact.StringId); hitCounter.HitExtensibilityPoints.Should().BeEmpty(); @@ -649,7 +649,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be(scholarship.Participants[0].StringId); responseDocument.Data.ManyValue[1].Id.Should().Be(scholarship.Participants[1].StringId); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/AtomicOperationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/AtomicOperationTests.cs index 9ce92fbd6f..18253c7c7c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/AtomicOperationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/AtomicOperationTests.cs @@ -55,18 +55,18 @@ public async Task When_operation_is_enabled_on_base_type_it_is_implicitly_enable // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Results.ShouldHaveCount(1); + responseDocument.Results.Should().HaveCount(1); - responseDocument.Results[0].Data.SingleValue.ShouldNotBeNull().With(resource => + responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject.With(resource => { resource.Type.Should().Be("alwaysMovingTandems"); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(newMovingTandem.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(newMovingTandem.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(newMovingTandem.GearCount)); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(newMovingTandem.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(newMovingTandem.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(newMovingTandem.GearCount); resource.Relationships.Should().BeNull(); }); - long newMovingTandemId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.ShouldNotBeNull()); + long newMovingTandemId = long.Parse(responseDocument.Results[0].Data.SingleValue!.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ChangeTracking/ResourceInheritanceChangeTrackerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ChangeTracking/ResourceInheritanceChangeTrackerTests.cs index 7c05fe882f..0e1201bc8f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ChangeTracking/ResourceInheritanceChangeTrackerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ChangeTracking/ResourceInheritanceChangeTrackerTests.cs @@ -55,8 +55,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("alwaysMovingTandems"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("locationToken").With(value => value.Should().NotBe(existingMovingTandem.LocationToken)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("locationToken").WhoseValue.Should().NotBe(existingMovingTandem.LocationToken); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceReadTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceReadTests.cs index ec541d443d..04ee189d8a 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceReadTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceReadTests.cs @@ -73,29 +73,29 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/bikes/{bike.StringId}"); - resource.Attributes.ShouldHaveCount(3); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(bike.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(bike.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(bike.GearCount)); + resource.Attributes.Should().HaveCount(3); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(bike.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(bike.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(bike.GearCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/bikes/{bike.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/bikes/{bike.StringId}/{name}"); } @@ -105,21 +105,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { resource.Id.Should().Be(tandem.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/tandems/{tandem.StringId}"); - resource.Attributes.ShouldHaveCount(4); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(tandem.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(tandem.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(tandem.GearCount)); - resource.Attributes.ShouldContainKey("passengerCount").With(value => value.Should().Be(tandem.PassengerCount)); + resource.Attributes.Should().HaveCount(4); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(tandem.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(tandem.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(tandem.GearCount); + resource.Attributes.Should().ContainKey("passengerCount").WhoseValue.Should().Be(tandem.PassengerCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/tandems/{tandem.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/tandems/{tandem.StringId}/{name}"); } @@ -129,21 +129,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { resource.Id.Should().Be(car.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/cars/{car.StringId}"); - resource.Attributes.ShouldHaveCount(4); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(car.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(car.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("licensePlate").With(value => value.Should().Be(car.LicensePlate)); - resource.Attributes.ShouldContainKey("seatCount").With(value => value.Should().Be(car.SeatCount)); + resource.Attributes.Should().HaveCount(4); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(car.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(car.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("licensePlate").WhoseValue.Should().Be(car.LicensePlate); + resource.Attributes.Should().ContainKey("seatCount").WhoseValue.Should().Be(car.SeatCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "features"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "features"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/cars/{car.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/cars/{car.StringId}/{name}"); } @@ -153,21 +153,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { resource.Id.Should().Be(truck.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/trucks/{truck.StringId}"); - resource.Attributes.ShouldHaveCount(4); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(truck.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(truck.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("licensePlate").With(value => value.Should().Be(truck.LicensePlate)); - resource.Attributes.ShouldContainKey("loadingCapacity").With(value => value.Should().Be(truck.LoadingCapacity)); + resource.Attributes.Should().HaveCount(4); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(truck.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(truck.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("licensePlate").WhoseValue.Should().Be(truck.LicensePlate); + resource.Attributes.Should().ContainKey("loadingCapacity").WhoseValue.Should().Be(truck.LoadingCapacity); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "sleepingArea", "features"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "sleepingArea", "features"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/trucks/{truck.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/trucks/{truck.StringId}/{name}"); } @@ -196,29 +196,29 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/bikes/{bike.StringId}"); - resource.Attributes.ShouldHaveCount(3); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(bike.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(bike.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(bike.GearCount)); + resource.Attributes.Should().HaveCount(3); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(bike.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(bike.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(bike.GearCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/bikes/{bike.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/bikes/{bike.StringId}/{name}"); } @@ -228,21 +228,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { resource.Id.Should().Be(tandem.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/tandems/{tandem.StringId}"); - resource.Attributes.ShouldHaveCount(4); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(tandem.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(tandem.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(tandem.GearCount)); - resource.Attributes.ShouldContainKey("passengerCount").With(value => value.Should().Be(tandem.PassengerCount)); + resource.Attributes.Should().HaveCount(4); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(tandem.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(tandem.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(tandem.GearCount); + resource.Attributes.Should().ContainKey("passengerCount").WhoseValue.Should().Be(tandem.PassengerCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/tandems/{tandem.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/tandems/{tandem.StringId}/{name}"); } @@ -271,30 +271,30 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems").Subject.With(resource => { resource.Id.Should().Be(tandem.StringId); - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/tandems/{tandem.StringId}"); - resource.Attributes.ShouldHaveCount(4); - resource.Attributes.ShouldContainKey("weight").With(value => value.Should().Be(tandem.Weight)); - resource.Attributes.ShouldContainKey("requiresDriverLicense").With(value => value.Should().Be(tandem.RequiresDriverLicense)); - resource.Attributes.ShouldContainKey("gearCount").With(value => value.Should().Be(tandem.GearCount)); - resource.Attributes.ShouldContainKey("passengerCount").With(value => value.Should().Be(tandem.PassengerCount)); + resource.Attributes.Should().HaveCount(4); + resource.Attributes.Should().ContainKey("weight").WhoseValue.Should().Be(tandem.Weight); + resource.Attributes.Should().ContainKey("requiresDriverLicense").WhoseValue.Should().Be(tandem.RequiresDriverLicense); + resource.Attributes.Should().ContainKey("gearCount").WhoseValue.Should().Be(tandem.GearCount); + resource.Attributes.Should().ContainKey("passengerCount").WhoseValue.Should().Be(tandem.PassengerCount); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); foreach ((string name, RelationshipObject? value) in resource.Relationships) { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/tandems/{tandem.StringId}/relationships/{name}"); value.Links.Related.Should().Be($"/tandems/{tandem.StringId}/{name}"); } @@ -321,11 +321,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("tandems"); responseDocument.Data.SingleValue.Id.Should().Be(tandem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); + + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys( + "manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); } [Fact] @@ -348,11 +350,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("tandems"); responseDocument.Data.SingleValue.Id.Should().Be(tandem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); + + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys( + "manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); } [Fact] @@ -375,11 +379,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("tandems"); responseDocument.Data.SingleValue.Id.Should().Be(tandem.StringId); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); + + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys( + "manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); } [Fact] @@ -420,11 +426,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("vehicleManufacturers"); responseDocument.Data.SingleValue.Id.Should().Be(manufacturer.StringId); - responseDocument.Included.ShouldNotBeNull(); + responseDocument.Included.Should().NotBeNull(); responseDocument.Included.Where(include => include.Type == "bicycleLights").Should().HaveCount(10); responseDocument.Included.Where(include => include.Type == "genericFeatures").Should().HaveCount(10 * 3); } @@ -450,28 +456,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("gasolineEngines"); responseDocument.Data.SingleValue.Id.Should().Be(car.Engine.StringId); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"/gasolineEngines/{car.Engine.StringId}"); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(4); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isHydrocarbonBased").With(value => value.Should().Be(car.Engine.IsHydrocarbonBased)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("capacity").With(value => value.Should().Be(car.Engine.Capacity)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("serialCode").With(value => value.Should().Be(((GasolineEngine)car.Engine).SerialCode)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("volatility").With(value => value.Should().Be(((GasolineEngine)car.Engine).Volatility)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(4); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isHydrocarbonBased").WhoseValue.Should().Be(car.Engine.IsHydrocarbonBased); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("capacity").WhoseValue.Should().Be(car.Engine.Capacity); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("serialCode").WhoseValue.Should().Be(((GasolineEngine)car.Engine).SerialCode); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("volatility").WhoseValue.Should().Be(((GasolineEngine)car.Engine).Volatility); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("cylinders").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("cylinders").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/gasolineEngines/{car.Engine.StringId}/relationships/cylinders"); value.Links.Related.Should().Be($"/gasolineEngines/{car.Engine.StringId}/cylinders"); }); @@ -498,19 +504,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("boxes"); responseDocument.Data.SingleValue.Id.Should().Be(tandem.CargoBox.StringId); responseDocument.Data.SingleValue.Links.Should().BeNull(); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(3); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("width").With(value => value.Should().Be(tandem.CargoBox.Width)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("height").With(value => value.Should().Be(tandem.CargoBox.Height)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("depth").With(value => value.Should().Be(tandem.CargoBox.Depth)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(3); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("width").WhoseValue.Should().Be(tandem.CargoBox.Width); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("height").WhoseValue.Should().Be(tandem.CargoBox.Height); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("depth").WhoseValue.Should().Be(tandem.CargoBox.Depth); responseDocument.Data.SingleValue.Relationships.Should().BeNull(); } @@ -536,28 +542,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("gasolineEngines"); responseDocument.Data.SingleValue.Id.Should().Be(car.Engine.StringId); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be($"/gasolineEngines/{car.Engine.StringId}"); - responseDocument.Data.SingleValue.Attributes.ShouldHaveCount(4); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("isHydrocarbonBased").With(value => value.Should().Be(car.Engine.IsHydrocarbonBased)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("capacity").With(value => value.Should().Be(car.Engine.Capacity)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("serialCode").With(value => value.Should().Be(((GasolineEngine)car.Engine).SerialCode)); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("volatility").With(value => value.Should().Be(((GasolineEngine)car.Engine).Volatility)); + responseDocument.Data.SingleValue.Attributes.Should().HaveCount(4); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("isHydrocarbonBased").WhoseValue.Should().Be(car.Engine.IsHydrocarbonBased); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("capacity").WhoseValue.Should().Be(car.Engine.Capacity); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("serialCode").WhoseValue.Should().Be(((GasolineEngine)car.Engine).SerialCode); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("volatility").WhoseValue.Should().Be(((GasolineEngine)car.Engine).Volatility); - responseDocument.Data.SingleValue.Relationships.ShouldHaveCount(1); + responseDocument.Data.SingleValue.Relationships.Should().HaveCount(1); - responseDocument.Data.SingleValue.Relationships.ShouldContainKey("cylinders").With(value => + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("cylinders").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/gasolineEngines/{car.Engine.StringId}/relationships/cylinders"); value.Links.Related.Should().Be($"/gasolineEngines/{car.Engine.StringId}/cylinders"); }); @@ -584,7 +590,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -614,7 +620,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -645,10 +651,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(0).StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(1).StringId); @@ -657,28 +663,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "chromeWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/chromeWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "paintColor"); + resource.Attributes.Should().OnlyContainKeys("radius", "paintColor"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "carbonWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/carbonWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "hasTube"); + resource.Attributes.Should().OnlyContainKeys("radius", "hasTube"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue) { - resource.Relationships.ShouldHaveCount(1); + resource.Relationships.Should().HaveCount(1); - resource.Relationships.ShouldContainKey("vehicle").With(value => + resource.Relationships.Should().ContainKey("vehicle").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/{resource.Type}/{resource.Id}/relationships/vehicle"); value.Links.Related.Should().Be($"/{resource.Type}/{resource.Id}/vehicle"); }); @@ -706,10 +712,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should() .ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == tandem.Wheels.ElementAt(0).StringId); @@ -725,28 +731,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "chromeWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/chromeWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "paintColor"); + resource.Attributes.Should().OnlyContainKeys("radius", "paintColor"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "carbonWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/carbonWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "hasTube"); + resource.Attributes.Should().OnlyContainKeys("radius", "hasTube"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue) { - resource.Relationships.ShouldHaveCount(1); + resource.Relationships.Should().HaveCount(1); - resource.Relationships.ShouldContainKey("vehicle").With(value => + resource.Relationships.Should().ContainKey("vehicle").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/{resource.Type}/{resource.Id}/relationships/vehicle"); value.Links.Related.Should().Be($"/{resource.Type}/{resource.Id}/vehicle"); }); @@ -775,10 +781,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(0).StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(1).StringId); @@ -787,28 +793,28 @@ await _testContext.RunOnDatabaseAsync(async dbContext => foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "chromeWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/chromeWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "paintColor"); + resource.Attributes.Should().OnlyContainKeys("radius", "paintColor"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue.Where(value => value.Type == "carbonWheels")) { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be($"/carbonWheels/{resource.Id}"); - resource.Attributes.ShouldOnlyContainKeys("radius", "hasTube"); + resource.Attributes.Should().OnlyContainKeys("radius", "hasTube"); } foreach (ResourceObject resource in responseDocument.Data.ManyValue) { - resource.Relationships.ShouldHaveCount(1); + resource.Relationships.Should().HaveCount(1); - resource.Relationships.ShouldContainKey("vehicle").With(value => + resource.Relationships.Should().ContainKey("vehicle").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Links.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); value.Links.Self.Should().Be($"/{resource.Type}/{resource.Id}/relationships/vehicle"); value.Links.Related.Should().Be($"/{resource.Type}/{resource.Id}/vehicle"); }); @@ -837,7 +843,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -867,7 +873,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -897,11 +903,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/motorVehicles/{car.StringId}/engine"); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("gasolineEngines"); responseDocument.Data.SingleValue.Id.Should().Be(car.Engine.StringId); responseDocument.Data.SingleValue.Links.Should().BeNull(); @@ -928,11 +934,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/bikes/{tandem.StringId}/cargoBox"); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("boxes"); responseDocument.Data.SingleValue.Id.Should().Be(tandem.CargoBox.StringId); responseDocument.Data.SingleValue.Links.Should().BeNull(); @@ -959,11 +965,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/cars/{car.StringId}/engine"); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("gasolineEngines"); responseDocument.Data.SingleValue.Id.Should().Be(car.Engine.StringId); responseDocument.Data.SingleValue.Links.Should().BeNull(); @@ -990,7 +996,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1021,11 +1027,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/vehicles/{car.StringId}/wheels"); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(0).StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(1).StringId); @@ -1059,11 +1065,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/bikes/{tandem.StringId}/wheels"); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should() .ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == tandem.Wheels.ElementAt(0).StringId); @@ -1105,11 +1111,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Links.ShouldNotBeNull(); + responseDocument.Links.Should().NotBeNull(); responseDocument.Links.Self.Should().Be(route); responseDocument.Links.Related.Should().Be($"/cars/{car.StringId}/wheels"); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(0).StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "chromeWheels" && resource.Id == car.Wheels.ElementAt(1).StringId); @@ -1144,7 +1150,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1174,7 +1180,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1217,34 +1223,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "gearCount"); - resource.Relationships.ShouldOnlyContainKeys("lights"); + resource.Attributes.Should().OnlyContainKeys("weight", "gearCount"); + resource.Relationships.Should().OnlyContainKeys("lights"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems").Subject.With(resource => { resource.Id.Should().Be(tandem.StringId); - resource.Attributes.ShouldOnlyContainKeys("gearCount", "passengerCount"); - resource.Relationships.ShouldOnlyContainKeys("cargoBox"); + resource.Attributes.Should().OnlyContainKeys("gearCount", "passengerCount"); + resource.Relationships.Should().OnlyContainKeys("cargoBox"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "cars").Subject.With(resource => { resource.Id.Should().Be(car.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "seatCount"); - resource.Relationships.ShouldOnlyContainKeys("engine"); + resource.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "seatCount"); + resource.Relationships.Should().OnlyContainKeys("engine"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "trucks").Subject.With(resource => { resource.Id.Should().Be(truck.StringId); - resource.Attributes.ShouldOnlyContainKeys("loadingCapacity"); - resource.Relationships.ShouldOnlyContainKeys("sleepingArea"); + resource.Attributes.Should().OnlyContainKeys("loadingCapacity"); + resource.Relationships.Should().OnlyContainKeys("sleepingArea"); }); } @@ -1280,34 +1286,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "gearCount"); - resource.Relationships.ShouldOnlyContainKeys("lights"); + resource.Attributes.Should().OnlyContainKeys("weight", "gearCount"); + resource.Relationships.Should().OnlyContainKeys("lights"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems").Subject.With(resource => { resource.Id.Should().Be(tandem.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "lights", "cargoBox", "foldingDimensions", "features"); + resource.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "lights", "cargoBox", "foldingDimensions", "features"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "cars").Subject.With(resource => { resource.Id.Should().Be(car.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "seatCount"); - resource.Relationships.ShouldOnlyContainKeys("engine"); + resource.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "seatCount"); + resource.Relationships.Should().OnlyContainKeys("engine"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "trucks").Subject.With(resource => { resource.Id.Should().Be(truck.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "licensePlate", "loadingCapacity"); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "sleepingArea", "features"); + resource.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "licensePlate", "loadingCapacity"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "sleepingArea", "features"); }); } @@ -1336,22 +1342,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "gearCount"); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "lights"); + resource.Attributes.Should().OnlyContainKeys("weight", "gearCount"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "lights"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems").Subject.With(resource => { resource.Id.Should().Be(tandem.StringId); - resource.Attributes.ShouldOnlyContainKeys("passengerCount"); - resource.Relationships.ShouldOnlyContainKeys("cargoBox"); + resource.Attributes.Should().OnlyContainKeys("passengerCount"); + resource.Relationships.Should().OnlyContainKeys("cargoBox"); }); } @@ -1379,22 +1385,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes").Subject.With(resource => { resource.Id.Should().Be(bike.StringId); - resource.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount"); - resource.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); + resource.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount"); + resource.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); }); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems").Subject.With(resource => { resource.Id.Should().Be(tandem.StringId); - resource.Attributes.ShouldOnlyContainKeys("passengerCount"); - resource.Relationships.ShouldOnlyContainKeys("cargoBox"); + resource.Attributes.Should().OnlyContainKeys("passengerCount"); + resource.Relationships.Should().OnlyContainKeys("cargoBox"); }); } @@ -2142,7 +2148,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "bikes" && resource.Id == bike.StringId); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems" && resource.Id == tandem.StringId); @@ -2177,7 +2183,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "trucks" && resource.Id == truck.StringId); } @@ -2209,7 +2215,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "trucks" && resource.Id == truck.StringId); } @@ -2244,7 +2250,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "trucks" && resource.Id == truck2.StringId); } @@ -2275,7 +2281,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "tandems" && resource.Id == tandem2.StringId); } @@ -2312,7 +2318,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue.Should().ContainSingle(resource => resource.Type == "cars" && resource.Id == car3.StringId); } @@ -2348,7 +2354,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue[0].Type.Should().Be("bikes"); responseDocument.Data.ManyValue[0].Id.Should().Be(bike2.StringId); @@ -2390,7 +2396,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Type.Should().Be("bikes"); responseDocument.Data.ManyValue[0].Id.Should().Be(bike.StringId); @@ -2432,7 +2438,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Type.Should().Be("cars"); responseDocument.Data.ManyValue[0].Id.Should().Be(car3.StringId); @@ -2457,13 +2463,13 @@ public async Task Cannot_sort_on_ambiguous_derived_attribute() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"Field 'serialCode' is defined on multiple types that derive from resource type 'engines'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -2480,13 +2486,13 @@ public async Task Cannot_sort_on_ambiguous_derived_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"Field 'features' is defined on multiple types that derive from resource type 'vehicles'. {parameterValue}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -2530,7 +2536,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(5); + responseDocument.Data.ManyValue.Should().HaveCount(5); responseDocument.Data.ManyValue[0].Type.Should().Be("chromeWheels"); responseDocument.Data.ManyValue[0].Id.Should().Be(chromeWheel3.StringId); @@ -2588,7 +2594,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(5); + responseDocument.Data.ManyValue.Should().HaveCount(5); responseDocument.Data.ManyValue[0].Type.Should().Be("chromeWheels"); responseDocument.Data.ManyValue[0].Id.Should().Be(chromeWheel3.StringId); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs index c0620b12e0..c3a1713947 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceInheritanceWriteTests.cs @@ -97,13 +97,13 @@ public async Task Cannot_create_abstract_resource_at_abstract_endpoint() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Abstract resource type found."); error.Detail.Should().Be("Resource type 'vehicles' is abstract."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); } @@ -192,12 +192,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("bikes"); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount"); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights"); - long newBikeId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newBikeId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -219,17 +219,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => bikeInDatabase.RequiresDriverLicense.Should().Be(newBike.RequiresDriverLicense); bikeInDatabase.GearCount.Should().Be(newBike.GearCount); - bikeInDatabase.Manufacturer.ShouldNotBeNull(); + bikeInDatabase.Manufacturer.Should().NotBeNull(); bikeInDatabase.Manufacturer.Id.Should().Be(existingManufacturer.Id); - bikeInDatabase.Wheels.ShouldHaveCount(1); + bikeInDatabase.Wheels.Should().HaveCount(1); bikeInDatabase.Wheels.ElementAt(0).Should().BeOfType(); bikeInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingChromeWheel.Id); - bikeInDatabase.CargoBox.ShouldNotBeNull(); + bikeInDatabase.CargoBox.Should().NotBeNull(); bikeInDatabase.CargoBox.Id.Should().Be(existingBox.Id); - bikeInDatabase.Lights.ShouldHaveCount(1); + bikeInDatabase.Lights.Should().HaveCount(1); bikeInDatabase.Lights.ElementAt(0).Id.Should().Be(existingLight.Id); }); @@ -333,12 +333,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("cars"); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "licensePlate", "seatCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "features"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "licensePlate", "seatCount"); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys("manufacturer", "wheels", "engine", "navigationSystem", "features"); - long newCarId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newCarId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -362,21 +362,21 @@ await _testContext.RunOnDatabaseAsync(async dbContext => carInDatabase.LicensePlate.Should().Be(newCar.LicensePlate); carInDatabase.SeatCount.Should().Be(newCar.SeatCount); - carInDatabase.Manufacturer.ShouldNotBeNull(); + carInDatabase.Manufacturer.Should().NotBeNull(); carInDatabase.Manufacturer.Id.Should().Be(existingManufacturer.Id); - carInDatabase.Wheels.ShouldHaveCount(1); + carInDatabase.Wheels.Should().HaveCount(1); carInDatabase.Wheels.ElementAt(0).Should().BeOfType(); carInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingCarbonWheel.Id); - carInDatabase.Engine.ShouldNotBeNull(); + carInDatabase.Engine.Should().NotBeNull(); carInDatabase.Engine.Should().BeOfType(); carInDatabase.Engine.Id.Should().Be(existingGasolineEngine.Id); - carInDatabase.NavigationSystem.ShouldNotBeNull(); + carInDatabase.NavigationSystem.Should().NotBeNull(); carInDatabase.NavigationSystem.Id.Should().Be(existingNavigationSystem.Id); - carInDatabase.Features.ShouldHaveCount(1); + carInDatabase.Features.Should().HaveCount(1); carInDatabase.Features.ElementAt(0).Id.Should().Be(existingFeature.Id); }); @@ -483,12 +483,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("tandems"); - responseDocument.Data.SingleValue.Attributes.ShouldOnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - responseDocument.Data.SingleValue.Relationships.ShouldOnlyContainKeys("manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + responseDocument.Data.SingleValue.Attributes.Should().OnlyContainKeys("weight", "requiresDriverLicense", "gearCount", "passengerCount"); - long newTandemId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + responseDocument.Data.SingleValue.Relationships.Should().OnlyContainKeys( + "manufacturer", "wheels", "cargoBox", "lights", "foldingDimensions", "features"); + + long newTandemId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -512,20 +514,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => tandemInDatabase.GearCount.Should().Be(newTandem.GearCount); tandemInDatabase.PassengerCount.Should().Be(newTandem.PassengerCount); - tandemInDatabase.Manufacturer.ShouldNotBeNull(); + tandemInDatabase.Manufacturer.Should().NotBeNull(); tandemInDatabase.Manufacturer.Id.Should().Be(existingManufacturer.Id); - tandemInDatabase.Wheels.ShouldHaveCount(1); + tandemInDatabase.Wheels.Should().HaveCount(1); tandemInDatabase.Wheels.ElementAt(0).Should().BeOfType(); tandemInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingChromeWheel.Id); - tandemInDatabase.CargoBox.ShouldNotBeNull(); + tandemInDatabase.CargoBox.Should().NotBeNull(); tandemInDatabase.CargoBox.Id.Should().Be(existingBox.Id); - tandemInDatabase.Lights.ShouldHaveCount(1); + tandemInDatabase.Lights.Should().HaveCount(1); tandemInDatabase.Lights.ElementAt(0).Id.Should().Be(existingLight.Id); - tandemInDatabase.Features.ShouldHaveCount(1); + tandemInDatabase.Features.Should().HaveCount(1); tandemInDatabase.Features.ElementAt(0).Id.Should().Be(existingFeature.Id); }); @@ -561,13 +563,13 @@ public async Task Cannot_create_concrete_base_resource_at_concrete_derived_endpo // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'bikes' is not convertible to type 'tandems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); } @@ -610,13 +612,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Abstract resource type found."); error.Detail.Should().Be("Resource type 'engines' is abstract."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/engine/data/type"); } @@ -661,19 +663,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("carbonWheels"); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - long newCarbonWheelId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newCarbonWheelId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { CarbonWheel carbonWheelInDatabase = await dbContext.CarbonWheels.Include(wheel => wheel.Vehicle).FirstWithIdAsync(newCarbonWheelId); carbonWheelInDatabase.Should().BeOfType(); - carbonWheelInDatabase.Vehicle.ShouldNotBeNull(); + carbonWheelInDatabase.Vehicle.Should().NotBeNull(); carbonWheelInDatabase.Vehicle.Should().BeOfType(); carbonWheelInDatabase.Vehicle.Id.Should().Be(existingTandem.Id); }); @@ -726,19 +728,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("vehicleManufacturers"); - responseDocument.Data.SingleValue.Attributes.ShouldNotBeEmpty(); - responseDocument.Data.SingleValue.Relationships.ShouldNotBeEmpty(); + responseDocument.Data.SingleValue.Attributes.Should().NotBeEmpty(); + responseDocument.Data.SingleValue.Relationships.Should().NotBeEmpty(); - long newManufacturerId = long.Parse(responseDocument.Data.SingleValue.Id.ShouldNotBeNull()); + long newManufacturerId = long.Parse(responseDocument.Data.SingleValue.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { VehicleManufacturer manufacturerInDatabase = await dbContext.VehicleManufacturers.Include(manufacturer => manufacturer.Vehicles) .FirstWithIdAsync(newManufacturerId); - manufacturerInDatabase.Vehicles.ShouldHaveCount(1); + manufacturerInDatabase.Vehicles.Should().HaveCount(1); manufacturerInDatabase.Vehicles.ElementAt(0).Should().BeOfType(); manufacturerInDatabase.Vehicles.ElementAt(0).Id.Should().Be(existingTandem.Id); }); @@ -786,7 +788,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -838,7 +840,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -880,7 +882,7 @@ public async Task Cannot_create_resource_with_unknown_resource_in_ToOne_relation // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -925,7 +927,7 @@ public async Task Cannot_create_resource_with_unknown_resources_in_ToMany_relati // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -969,13 +971,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Abstract resource type found."); error.Detail.Should().Be("Resource type 'vehicles' is abstract."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); } @@ -1090,17 +1092,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => bikeInDatabase.RequiresDriverLicense.Should().Be(newBike.RequiresDriverLicense); bikeInDatabase.GearCount.Should().Be(newBike.GearCount); - bikeInDatabase.Manufacturer.ShouldNotBeNull(); + bikeInDatabase.Manufacturer.Should().NotBeNull(); bikeInDatabase.Manufacturer.Id.Should().Be(existingManufacturer.Id); - bikeInDatabase.Wheels.ShouldHaveCount(1); + bikeInDatabase.Wheels.Should().HaveCount(1); bikeInDatabase.Wheels.ElementAt(0).Should().BeOfType(); bikeInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingChromeWheel.Id); - bikeInDatabase.CargoBox.ShouldNotBeNull(); + bikeInDatabase.CargoBox.Should().NotBeNull(); bikeInDatabase.CargoBox.Id.Should().Be(existingBox.Id); - bikeInDatabase.Lights.ShouldHaveCount(1); + bikeInDatabase.Lights.Should().HaveCount(1); bikeInDatabase.Lights.ElementAt(0).Id.Should().Be(existingLight.Id); }); @@ -1219,17 +1221,17 @@ await _testContext.RunOnDatabaseAsync(async dbContext => tandemInDatabase.RequiresDriverLicense.Should().Be(newBike.RequiresDriverLicense); tandemInDatabase.GearCount.Should().Be(newBike.GearCount); - tandemInDatabase.Manufacturer.ShouldNotBeNull(); + tandemInDatabase.Manufacturer.Should().NotBeNull(); tandemInDatabase.Manufacturer.Id.Should().Be(existingManufacturer.Id); - tandemInDatabase.Wheels.ShouldHaveCount(1); + tandemInDatabase.Wheels.Should().HaveCount(1); tandemInDatabase.Wheels.ElementAt(0).Should().BeOfType(); tandemInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingChromeWheel.Id); - tandemInDatabase.CargoBox.ShouldNotBeNull(); + tandemInDatabase.CargoBox.Should().NotBeNull(); tandemInDatabase.CargoBox.Id.Should().Be(existingBox.Id); - tandemInDatabase.Lights.ShouldHaveCount(1); + tandemInDatabase.Lights.Should().HaveCount(1); tandemInDatabase.Lights.ElementAt(0).Id.Should().Be(existingLight.Id); }); @@ -1272,13 +1274,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Conflict); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Conflict); error.Title.Should().Be("Failed to deserialize request body: Incompatible resource type found."); error.Detail.Should().Be("Type 'bikes' is not convertible to type 'tandems'."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); } @@ -1326,13 +1328,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.UnprocessableEntity); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Abstract resource type found."); error.Detail.Should().Be("Resource type 'engines' is abstract."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/engine/data/type"); } @@ -1388,7 +1390,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => CarbonWheel carbonWheelInDatabase = await dbContext.CarbonWheels.Include(wheel => wheel.Vehicle).FirstWithIdAsync(existingCarbonWheel.Id); carbonWheelInDatabase.Should().BeOfType(); - carbonWheelInDatabase.Vehicle.ShouldNotBeNull(); + carbonWheelInDatabase.Vehicle.Should().NotBeNull(); carbonWheelInDatabase.Vehicle.Should().BeOfType(); carbonWheelInDatabase.Vehicle.Id.Should().Be(existingTandem.Id); }); @@ -1452,7 +1454,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => VehicleManufacturer manufacturerInDatabase = await dbContext.VehicleManufacturers.Include(manufacturer => manufacturer.Vehicles) .FirstWithIdAsync(existingManufacturer.Id); - manufacturerInDatabase.Vehicles.ShouldHaveCount(1); + manufacturerInDatabase.Vehicles.Should().HaveCount(1); manufacturerInDatabase.Vehicles.ElementAt(0).Should().BeOfType(); manufacturerInDatabase.Vehicles.ElementAt(0).Id.Should().Be(existingTandem.Id); }); @@ -1504,7 +1506,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1560,7 +1562,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1611,7 +1613,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1665,7 +1667,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1729,7 +1731,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1780,7 +1782,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => wheelInDatabase.Should().BeOfType(); - wheelInDatabase.Vehicle.ShouldNotBeNull(); + wheelInDatabase.Vehicle.Should().NotBeNull(); wheelInDatabase.Vehicle.Should().BeOfType(); wheelInDatabase.Vehicle.Id.Should().Be(existingTandem.Id); }); @@ -1834,7 +1836,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => vehicleInDatabase.Should().BeOfType(); - vehicleInDatabase.Wheels.ShouldHaveCount(1); + vehicleInDatabase.Wheels.Should().HaveCount(1); vehicleInDatabase.Wheels.ElementAt(0).Should().BeOfType(); vehicleInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingChromeWheel.Id); }); @@ -1885,7 +1887,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => wheelInDatabase.Should().BeOfType(); - wheelInDatabase.Vehicle.ShouldNotBeNull(); + wheelInDatabase.Vehicle.Should().NotBeNull(); wheelInDatabase.Vehicle.Should().BeOfType(); wheelInDatabase.Vehicle.Id.Should().Be(existingTandem.Id); }); @@ -1938,7 +1940,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => VehicleManufacturer manufacturerInDatabase = await dbContext.VehicleManufacturers.Include(manufacturer => manufacturer.Vehicles) .FirstWithIdAsync(existingManufacturer.Id); - manufacturerInDatabase.Vehicles.ShouldHaveCount(1); + manufacturerInDatabase.Vehicles.Should().HaveCount(1); manufacturerInDatabase.Vehicles.ElementAt(0).Should().BeOfType(); manufacturerInDatabase.Vehicles.ElementAt(0).Id.Should().Be(existingTandem.Id); }); @@ -1979,7 +1981,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2024,7 +2026,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2067,7 +2069,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2101,7 +2103,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2156,7 +2158,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => vehicleInDatabase.Should().BeOfType(); - vehicleInDatabase.Wheels.ShouldHaveCount(2); + vehicleInDatabase.Wheels.Should().HaveCount(2); vehicleInDatabase.Wheels.ElementAt(0).Should().BeOfType(); vehicleInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingTandem.Wheels.ElementAt(0).Id); vehicleInDatabase.Wheels.ElementAt(1).Should().BeOfType(); @@ -2213,7 +2215,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => vehicleInDatabase.Should().BeOfType(); - vehicleInDatabase.Wheels.ShouldHaveCount(2); + vehicleInDatabase.Wheels.Should().HaveCount(2); vehicleInDatabase.Wheels.ElementAt(0).Should().BeOfType(); vehicleInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingTandem.Wheels.ElementAt(0).Id); vehicleInDatabase.Wheels.ElementAt(1).Should().BeOfType(); @@ -2277,7 +2279,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_after_property_in_chained_method_calls restore // @formatter:wrap_chained_method_calls restore - manufacturerInDatabase.Vehicles.ShouldHaveCount(2); + manufacturerInDatabase.Vehicles.Should().HaveCount(2); manufacturerInDatabase.Vehicles.ElementAt(0).Should().BeOfType(); manufacturerInDatabase.Vehicles.ElementAt(0).Id.Should().Be(existingManufacturer.Vehicles.ElementAt(0).Id); manufacturerInDatabase.Vehicles.ElementAt(1).Should().BeOfType(); @@ -2323,7 +2325,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2366,7 +2368,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2400,7 +2402,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2452,7 +2454,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => vehicleInDatabase.Should().BeOfType(); - vehicleInDatabase.Wheels.ShouldHaveCount(1); + vehicleInDatabase.Wheels.Should().HaveCount(1); vehicleInDatabase.Wheels.ElementAt(0).Should().BeOfType(); vehicleInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingTandem.Wheels.ElementAt(1).Id); }); @@ -2504,7 +2506,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => vehicleInDatabase.Should().BeOfType(); - vehicleInDatabase.Wheels.ShouldHaveCount(1); + vehicleInDatabase.Wheels.Should().HaveCount(1); vehicleInDatabase.Wheels.ElementAt(0).Should().BeOfType(); vehicleInDatabase.Wheels.ElementAt(0).Id.Should().Be(existingTandem.Wheels.ElementAt(1).Id); }); @@ -2556,7 +2558,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => VehicleManufacturer manufacturerInDatabase = await dbContext.VehicleManufacturers.Include(manufacturer => manufacturer.Vehicles) .FirstWithIdAsync(existingManufacturer.Id); - manufacturerInDatabase.Vehicles.ShouldHaveCount(1); + manufacturerInDatabase.Vehicles.Should().HaveCount(1); manufacturerInDatabase.Vehicles.ElementAt(0).Should().BeOfType(); manufacturerInDatabase.Vehicles.ElementAt(0).Id.Should().Be(existingManufacturer.Vehicles.ElementAt(1).Id); }); @@ -2598,7 +2600,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); string? chromeWheelId = existingBike.Wheels.ElementAt(0).StringId; @@ -2643,7 +2645,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -2677,7 +2679,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCaptureStore.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCaptureStore.cs index d3eeaedb61..355b779779 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCaptureStore.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/ResourceTypeCaptureStore.cs @@ -2,7 +2,6 @@ using FluentAssertions; using JsonApiDotNetCore.Middleware; -using TestBuildingBlocks; namespace JsonApiDotNetCoreTests.IntegrationTests.ResourceInheritance; @@ -26,15 +25,15 @@ internal void AssertLeftType() LeftDeclaredType.Should().Be(); LeftReflectedTypeName.Should().Be(typeof(TLeft).Name); - Request.ShouldNotBeNull(); - Request.PrimaryResourceType.ShouldNotBeNull(); + Request.Should().NotBeNull(); + Request.PrimaryResourceType.Should().NotBeNull(); Request.PrimaryResourceType.ClrType.Should().Be(); Request.Relationship?.LeftType.ClrType.Should().Be(); } internal void AssertRightTypes(params Type[] types) { - RightTypeNames.ShouldHaveCount(types.Length); + RightTypeNames.Should().HaveCount(types.Length); foreach (Type type in types) { diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/DisableQueryStringTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/DisableQueryStringTests.cs index 22044421e2..5415d79f14 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/DisableQueryStringTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/DisableQueryStringTests.cs @@ -38,13 +38,13 @@ public async Task Cannot_sort_if_query_string_parameter_is_blocked_by_controller // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'sort' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } @@ -60,13 +60,13 @@ public async Task Cannot_paginate_if_query_string_parameter_is_blocked_by_contro // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'page[number]' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -82,7 +82,7 @@ public async Task Can_use_custom_query_string_parameter() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.ShouldNotBeEmpty(); + responseDocument.Should().NotBeEmpty(); } [Fact] @@ -97,13 +97,13 @@ public async Task Cannot_use_custom_query_string_parameter_if_blocked_by_control // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.BadRequest); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Usage of one or more query string parameters is not allowed at the requested endpoint."); error.Detail.Should().Be("The parameter 'skipCache' cannot be used at this endpoint."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("skipCache"); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/NoRelationshipsControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/NoRelationshipsControllerTests.cs index 0581b527e1..b5453c6112 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/NoRelationshipsControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/NoRelationshipsControllerTests.cs @@ -72,7 +72,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -100,7 +100,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -128,7 +128,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -239,7 +239,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -272,7 +272,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -305,7 +305,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/ReadOnlyControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/ReadOnlyControllerTests.cs index 40c07d57bf..bacdab9e6f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/ReadOnlyControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/ReadOnlyControllerTests.cs @@ -138,7 +138,7 @@ public async Task Cannot_create_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -178,7 +178,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -206,7 +206,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -239,7 +239,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -272,7 +272,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -305,7 +305,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/WriteOnlyControllerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/WriteOnlyControllerTests.cs index 35e15b402c..a9c35de96f 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/WriteOnlyControllerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/RestrictedControllers/WriteOnlyControllerTests.cs @@ -30,7 +30,7 @@ public async Task Cannot_get_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -58,7 +58,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -114,7 +114,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.Forbidden); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.Forbidden); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/Serialization/ETagTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/Serialization/ETagTests.cs index 326fecad7f..1b866d8c48 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/Serialization/ETagTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/Serialization/ETagTests.cs @@ -41,9 +41,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Headers.ETag.ShouldNotBeNull(); + httpResponse.Headers.ETag.Should().NotBeNull(); httpResponse.Headers.ETag.IsWeak.Should().BeFalse(); - httpResponse.Headers.ETag.Tag.ShouldNotBeNullOrEmpty(); + httpResponse.Headers.ETag.Tag.Should().NotBeNullOrEmpty(); responseDocument.Should().BeEmpty(); } @@ -69,11 +69,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Headers.ETag.ShouldNotBeNull(); + httpResponse.Headers.ETag.Should().NotBeNull(); httpResponse.Headers.ETag.IsWeak.Should().BeFalse(); - httpResponse.Headers.ETag.Tag.ShouldNotBeNullOrEmpty(); + httpResponse.Headers.ETag.Tag.Should().NotBeNullOrEmpty(); - responseDocument.ShouldNotBeEmpty(); + responseDocument.Should().NotBeEmpty(); } [Fact] @@ -90,7 +90,7 @@ public async Task Returns_no_ETag_for_failed_GET_request() httpResponse.Headers.ETag.Should().BeNull(); - responseDocument.ShouldNotBeEmpty(); + responseDocument.Should().NotBeEmpty(); } [Fact] @@ -123,7 +123,7 @@ public async Task Returns_no_ETag_for_POST_request() httpResponse.Headers.ETag.Should().BeNull(); - responseDocument.ShouldNotBeEmpty(); + responseDocument.Should().NotBeEmpty(); } [Fact] @@ -163,13 +163,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.PreconditionFailed); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.PreconditionFailed); error.Title.Should().Be("Detection of mid-air edit collisions using ETags is not supported."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Header.Should().Be("If-Match"); } @@ -200,9 +200,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse2.ShouldHaveStatusCode(HttpStatusCode.NotModified); - httpResponse2.Headers.ETag.ShouldNotBeNull(); + httpResponse2.Headers.ETag.Should().NotBeNull(); httpResponse2.Headers.ETag.IsWeak.Should().BeFalse(); - httpResponse2.Headers.ETag.Tag.ShouldNotBeNullOrEmpty(); + httpResponse2.Headers.ETag.Tag.Should().NotBeNullOrEmpty(); responseDocument2.Should().BeEmpty(); } @@ -230,10 +230,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - httpResponse.Headers.ETag.ShouldNotBeNull(); + httpResponse.Headers.ETag.Should().NotBeNull(); httpResponse.Headers.ETag.IsWeak.Should().BeFalse(); - httpResponse.Headers.ETag.Tag.ShouldNotBeNullOrEmpty(); + httpResponse.Headers.ETag.Tag.Should().NotBeNullOrEmpty(); - responseDocument.ShouldNotBeEmpty(); + responseDocument.Should().NotBeEmpty(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs index d8c10f2d1e..2badb7e252 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/SoftDeletion/SoftDeletionTests.cs @@ -60,7 +60,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(departments[1].StringId); } @@ -92,7 +92,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(departments[0].StringId); } @@ -123,11 +123,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Type.Should().Be("companies"); responseDocument.Data.ManyValue[0].Id.Should().Be(companies[1].StringId); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Type.Should().Be("departments"); responseDocument.Included[0].Id.Should().Be(companies[1].Departments.ElementAt(0).StringId); } @@ -153,7 +153,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -183,7 +183,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -213,7 +213,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(company.Departments.ElementAt(1).StringId); } @@ -239,7 +239,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -294,7 +294,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -324,7 +324,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(company.Departments.ElementAt(1).StringId); } @@ -350,7 +350,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -432,7 +432,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -488,7 +488,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -532,7 +532,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -586,7 +586,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -639,7 +639,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -674,7 +674,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -717,7 +717,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -753,7 +753,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -793,7 +793,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -836,7 +836,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -879,7 +879,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -923,7 +923,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -965,7 +965,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -1002,7 +1002,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => Company companyInDatabase = await dbContext.Companies.IgnoreQueryFilters().FirstWithIdAsync(existingCompany.Id); companyInDatabase.Name.Should().Be(existingCompany.Name); - companyInDatabase.SoftDeletedAt.ShouldNotBeNull(); + companyInDatabase.SoftDeletedAt.Should().NotBeNull(); }); } @@ -1027,7 +1027,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/EmptyGuidAsKeyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/EmptyGuidAsKeyTests.cs index 1fa313fa71..e836c049bf 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/EmptyGuidAsKeyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/EmptyGuidAsKeyTests.cs @@ -48,12 +48,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be("00000000-0000-0000-0000-000000000000"); responseDocument.Data.ManyValue[0].With(resource => { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be("/maps/00000000-0000-0000-0000-000000000000"); }); } @@ -82,12 +82,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("00000000-0000-0000-0000-000000000000"); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be("/maps/00000000-0000-0000-0000-000000000000"); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be("0"); } @@ -131,7 +131,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Map mapInDatabase = await dbContext.Maps.FirstWithIdAsync((Guid?)Guid.Empty); - mapInDatabase.ShouldNotBeNull(); + mapInDatabase.Should().NotBeNull(); mapInDatabase.Name.Should().Be(newName); }); } @@ -179,7 +179,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Map mapInDatabase = await dbContext.Maps.FirstWithIdAsync((Guid?)Guid.Empty); - mapInDatabase.ShouldNotBeNull(); + mapInDatabase.Should().NotBeNull(); mapInDatabase.Name.Should().Be(newName); }); } @@ -218,7 +218,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActiveMap).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.ActiveMap.Should().BeNull(); }); } @@ -262,8 +262,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActiveMap).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActiveMap.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActiveMap.Should().NotBeNull(); gameInDatabase.ActiveMap.Id.Should().Be(Guid.Empty); }); } @@ -308,8 +308,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActiveMap).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActiveMap.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActiveMap.Should().NotBeNull(); gameInDatabase.ActiveMap.Id.Should().Be(Guid.Empty); }); } @@ -348,7 +348,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Maps).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.Maps.Should().BeEmpty(); }); } @@ -395,8 +395,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Maps).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Maps.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Maps.Should().HaveCount(1); gameInDatabase.Maps.ElementAt(0).Id.Should().Be(Guid.Empty); }); } @@ -444,8 +444,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Maps).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Maps.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Maps.Should().HaveCount(1); gameInDatabase.Maps.ElementAt(0).Id.Should().Be(Guid.Empty); }); } @@ -493,8 +493,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Maps).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Maps.ShouldHaveCount(2); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Maps.Should().HaveCount(2); gameInDatabase.Maps.Should().ContainSingle(map => map.Id == Guid.Empty); }); } @@ -540,8 +540,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Maps).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Maps.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Maps.Should().HaveCount(1); gameInDatabase.Maps.Should().ContainSingle(map => map.Id != Guid.Empty); }); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/WhiteSpaceAsKeyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/WhiteSpaceAsKeyTests.cs index 249026e82d..2ed32314e0 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/WhiteSpaceAsKeyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/WhiteSpaceAsKeyTests.cs @@ -67,12 +67,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be(SingleSpace); responseDocument.Data.ManyValue[0].With(resource => { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be("/players/%20"); }); } @@ -101,12 +101,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(SingleSpace); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be("/players/%20"); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be("0"); } @@ -150,7 +150,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.FirstWithIdAsync((string?)SingleSpace); - playerInDatabase.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); playerInDatabase.EmailAddress.Should().Be(newEmailAddress); }); } @@ -198,7 +198,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.FirstWithIdAsync((string?)SingleSpace); - playerInDatabase.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); playerInDatabase.EmailAddress.Should().Be(newEmailAddress); }); } @@ -237,7 +237,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Host).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.Host.Should().BeNull(); }); } @@ -281,8 +281,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Host).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Host.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Host.Should().NotBeNull(); gameInDatabase.Host.Id.Should().Be(SingleSpace); }); } @@ -327,8 +327,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.Host).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.Host.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.Host.Should().NotBeNull(); gameInDatabase.Host.Id.Should().Be(SingleSpace); }); } @@ -367,7 +367,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActivePlayers).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.ActivePlayers.Should().BeEmpty(); }); } @@ -414,8 +414,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActivePlayers).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActivePlayers.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActivePlayers.Should().HaveCount(1); gameInDatabase.ActivePlayers.ElementAt(0).Id.Should().Be(SingleSpace); }); } @@ -463,8 +463,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActivePlayers).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActivePlayers.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActivePlayers.Should().HaveCount(1); gameInDatabase.ActivePlayers.ElementAt(0).Id.Should().Be(SingleSpace); }); } @@ -512,8 +512,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActivePlayers).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActivePlayers.ShouldHaveCount(2); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActivePlayers.Should().HaveCount(2); gameInDatabase.ActivePlayers.Should().ContainSingle(player => player.Id == SingleSpace); }); } @@ -559,8 +559,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.Include(game => game.ActivePlayers).FirstWithIdAsync(existingGame.Id); - gameInDatabase.ShouldNotBeNull(); - gameInDatabase.ActivePlayers.ShouldHaveCount(1); + gameInDatabase.Should().NotBeNull(); + gameInDatabase.ActivePlayers.Should().HaveCount(1); gameInDatabase.ActivePlayers.Should().ContainSingle(player => player.Id != SingleSpace); }); } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/ZeroAsKeyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/ZeroAsKeyTests.cs index a0ca13c4fa..56b5be0e8c 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/ZeroAsKeyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ZeroKeys/ZeroAsKeyTests.cs @@ -48,12 +48,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be("0"); responseDocument.Data.ManyValue[0].With(resource => { - resource.Links.ShouldNotBeNull(); + resource.Links.Should().NotBeNull(); resource.Links.Self.Should().Be("/games/0"); }); } @@ -81,12 +81,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("0"); - responseDocument.Data.SingleValue.Links.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Links.Should().NotBeNull(); responseDocument.Data.SingleValue.Links.Self.Should().Be("/games/0"); - responseDocument.Included.ShouldHaveCount(1); + responseDocument.Included.Should().HaveCount(1); responseDocument.Included[0].Id.Should().Be(game.ActivePlayers.ElementAt(0).StringId); } @@ -124,14 +124,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => httpResponse.Headers.Location.Should().Be("/games/0"); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("0"); await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.FirstWithIdAsync((int?)0); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.Title.Should().Be(newTitle); }); } @@ -173,15 +173,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("0"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("title").With(value => value.Should().Be(newTitle)); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("title").WhoseValue.Should().Be(newTitle); await _testContext.RunOnDatabaseAsync(async dbContext => { Game gameInDatabase = await dbContext.Games.FirstWithIdAsync((int?)0); - gameInDatabase.ShouldNotBeNull(); + gameInDatabase.Should().NotBeNull(); gameInDatabase.Title.Should().Be(newTitle); }); } @@ -220,7 +220,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.ActiveGame).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); playerInDatabase.ActiveGame.Should().BeNull(); }); } @@ -264,8 +264,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.ActiveGame).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.ActiveGame.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.ActiveGame.Should().NotBeNull(); playerInDatabase.ActiveGame.Id.Should().Be(0); }); } @@ -310,8 +310,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.ActiveGame).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.ActiveGame.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.ActiveGame.Should().NotBeNull(); playerInDatabase.ActiveGame.Id.Should().Be(0); }); } @@ -350,7 +350,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.RecentlyPlayed).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); + playerInDatabase.Should().NotBeNull(); playerInDatabase.RecentlyPlayed.Should().BeEmpty(); }); } @@ -397,8 +397,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.RecentlyPlayed).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.RecentlyPlayed.ShouldHaveCount(1); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.RecentlyPlayed.Should().HaveCount(1); playerInDatabase.RecentlyPlayed.ElementAt(0).Id.Should().Be(0); }); } @@ -446,8 +446,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.RecentlyPlayed).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.RecentlyPlayed.ShouldHaveCount(1); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.RecentlyPlayed.Should().HaveCount(1); playerInDatabase.RecentlyPlayed.ElementAt(0).Id.Should().Be(0); }); } @@ -495,8 +495,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.RecentlyPlayed).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.RecentlyPlayed.ShouldHaveCount(2); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.RecentlyPlayed.Should().HaveCount(2); playerInDatabase.RecentlyPlayed.Should().ContainSingle(game => game.Id == 0); }); } @@ -542,8 +542,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Player playerInDatabase = await dbContext.Players.Include(player => player.RecentlyPlayed).FirstWithIdAsync(existingPlayer.Id); - playerInDatabase.ShouldNotBeNull(); - playerInDatabase.RecentlyPlayed.ShouldHaveCount(1); + playerInDatabase.Should().NotBeNull(); + playerInDatabase.RecentlyPlayed.Should().HaveCount(1); playerInDatabase.RecentlyPlayed.Should().ContainSingle(game => game.Id != 0); }); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Links/LinkInclusionTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Links/LinkInclusionTests.cs index 9b8890618a..b6d7c8b618 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Links/LinkInclusionTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Links/LinkInclusionTests.cs @@ -10,7 +10,6 @@ using JsonApiDotNetCore.Serialization.Response; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.Links; @@ -116,11 +115,11 @@ public void Applies_cascading_settings_for_top_level_links(LinkTypes linksInReso } else { - topLevelLinks.ShouldNotBeNull(); + topLevelLinks.Should().NotBeNull(); if (expected.HasFlag(LinkTypes.Self)) { - topLevelLinks.Self.ShouldNotBeNull(); + topLevelLinks.Self.Should().NotBeNull(); } else { @@ -129,7 +128,7 @@ public void Applies_cascading_settings_for_top_level_links(LinkTypes linksInReso if (expected.HasFlag(LinkTypes.Related)) { - topLevelLinks.Related.ShouldNotBeNull(); + topLevelLinks.Related.Should().NotBeNull(); } else { @@ -138,10 +137,10 @@ public void Applies_cascading_settings_for_top_level_links(LinkTypes linksInReso if (expected.HasFlag(LinkTypes.Pagination)) { - topLevelLinks.First.ShouldNotBeNull(); - topLevelLinks.Last.ShouldNotBeNull(); - topLevelLinks.Prev.ShouldNotBeNull(); - topLevelLinks.Next.ShouldNotBeNull(); + topLevelLinks.First.Should().NotBeNull(); + topLevelLinks.Last.Should().NotBeNull(); + topLevelLinks.Prev.Should().NotBeNull(); + topLevelLinks.Next.Should().NotBeNull(); } else { @@ -198,8 +197,8 @@ public void Applies_cascading_settings_for_resource_links(LinkTypes linksInResou // Assert if (expected == LinkTypes.Self) { - resourceLinks.ShouldNotBeNull(); - resourceLinks.Self.ShouldNotBeNull(); + resourceLinks.Should().NotBeNull(); + resourceLinks.Self.Should().NotBeNull(); } else { @@ -372,11 +371,11 @@ public void Applies_cascading_settings_for_relationship_links(LinkTypes linksInR } else { - relationshipLinks.ShouldNotBeNull(); + relationshipLinks.Should().NotBeNull(); if (expected.HasFlag(LinkTypes.Self)) { - relationshipLinks.Self.ShouldNotBeNull(); + relationshipLinks.Self.Should().NotBeNull(); } else { @@ -385,7 +384,7 @@ public void Applies_cascading_settings_for_relationship_links(LinkTypes linksInR if (expected.HasFlag(LinkTypes.Related)) { - relationshipLinks.Related.ShouldNotBeNull(); + relationshipLinks.Related.Should().NotBeNull(); } else { diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Middleware/JsonApiMiddlewareTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Middleware/JsonApiMiddlewareTests.cs index fbd577d51d..ad1f5df24f 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Middleware/JsonApiMiddlewareTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Middleware/JsonApiMiddlewareTests.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.Extensions.Logging.Abstractions; -using TestBuildingBlocks; using Xunit; #pragma warning disable AV1561 // Signature contains too many parameters @@ -89,7 +88,7 @@ public async Task Sets_request_properties_correctly(string requestMethod, string } else { - request.PrimaryResourceType.ShouldNotBeNull(); + request.PrimaryResourceType.Should().NotBeNull(); request.PrimaryResourceType.PublicName.Should().Be(expectPrimaryResourceType); } @@ -99,7 +98,7 @@ public async Task Sets_request_properties_correctly(string requestMethod, string } else { - request.SecondaryResourceType.ShouldNotBeNull(); + request.SecondaryResourceType.Should().NotBeNull(); request.SecondaryResourceType.PublicName.Should().Be(expectSecondaryResourceType); } @@ -109,7 +108,7 @@ public async Task Sets_request_properties_correctly(string requestMethod, string } else { - request.Relationship.ShouldNotBeNull(); + request.Relationship.Should().NotBeNull(); request.Relationship.PublicName.Should().Be(expectRelationshipName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/ModelStateValidation/ModelStateValidationTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/ModelStateValidation/ModelStateValidationTests.cs index 34bbc16d17..e3a0a26cd9 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/ModelStateValidation/ModelStateValidationTests.cs @@ -46,7 +46,7 @@ public void Renders_JSON_path_for_ModelState_key_in_resource_request(string mode var exception = new InvalidModelStateException(modelState, typeof(Parent), false, resourceGraph); // Assert - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); if (expectedJsonPath == null) { @@ -54,7 +54,7 @@ public void Renders_JSON_path_for_ModelState_key_in_resource_request(string mode } else { - exception.Errors[0].Source.ShouldNotBeNull().With(value => value.Pointer.Should().Be(expectedJsonPath)); + exception.Errors[0].Source.RefShould().NotBeNull().And.Subject.Pointer.Should().Be(expectedJsonPath); } } @@ -94,7 +94,7 @@ public void Renders_JSON_path_for_ModelState_key_in_operations_request(string mo var exception = new InvalidModelStateException(modelState, typeof(IList), false, resourceGraph, getOperationTypeCallback); // Assert - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); if (expectedJsonPath == null) { @@ -102,7 +102,7 @@ public void Renders_JSON_path_for_ModelState_key_in_operations_request(string mo } else { - exception.Errors[0].Source.ShouldNotBeNull().With(value => value.Pointer.Should().Be(expectedJsonPath)); + exception.Errors[0].Source.RefShould().NotBeNull().And.Subject.Pointer.Should().Be(expectedJsonPath); } } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/FilterParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/FilterParseTests.cs index 1b45cc577f..c9de843e56 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/FilterParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/FilterParseTests.cs @@ -82,13 +82,13 @@ public void Reader_Read_ParameterName_Fails(string parameterName, string errorMe InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterNameSource.Text); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterNameSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterNameSource.Text); } @@ -159,13 +159,13 @@ public void Reader_Read_ParameterValue_Fails(string parameterName, string parame InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/IncludeParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/IncludeParseTests.cs index fc3431da31..49a1027fb6 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/IncludeParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/IncludeParseTests.cs @@ -74,13 +74,13 @@ public void Reader_Read_Fails(string parameterName, string parameterValue, strin InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified include is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/LegacyFilterParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/LegacyFilterParseTests.cs index 5cbbcc1936..eae586ebdb 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/LegacyFilterParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/LegacyFilterParseTests.cs @@ -9,7 +9,6 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Serialization.Objects; using JsonApiDotNetCoreTests.IntegrationTests.QueryStrings; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.QueryStringParameters; @@ -49,13 +48,13 @@ public void Reader_Read_ParameterName_Fails(string parameterName, string errorMe InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be(errorMessage); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } @@ -78,13 +77,13 @@ public void Reader_Read_ParameterValue_Fails(string parameterName, string parame InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified filter is invalid."); error.Detail.Should().Be(errorMessage); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/PaginationParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/PaginationParseTests.cs index f6efc0e597..8020bbb01c 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/PaginationParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/PaginationParseTests.cs @@ -89,13 +89,13 @@ public void Reader_Read_Page_Number_Fails(string parameterValue, string errorMes InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be("page[number]"); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } @@ -134,13 +134,13 @@ public void Reader_Read_Page_Size_Fails(string parameterValue, string errorMessa InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be("page[size]"); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified pagination is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SortParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SortParseTests.cs index 77c52b3828..24832cbc7d 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SortParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SortParseTests.cs @@ -74,13 +74,13 @@ public void Reader_Read_ParameterName_Fails(string parameterName, string errorMe InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterNameSource.Text); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterNameSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterNameSource.Text); } @@ -126,13 +126,13 @@ public void Reader_Read_ParameterValue_Fails(string parameterName, string parame InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified sort is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SparseFieldSetParseTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SparseFieldSetParseTests.cs index 51906bb613..19991bacae 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SparseFieldSetParseTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/QueryStringParameters/SparseFieldSetParseTests.cs @@ -73,13 +73,13 @@ public void Reader_Read_ParameterName_Fails(string parameterName, string errorMe InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterNameSource.Text); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterNameSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterNameSource.Text); } @@ -103,13 +103,13 @@ public void Reader_Read_ParameterValue_Fails(string parameterName, string parame InvalidQueryStringParameterException exception = action.Should().ThrowExactly().And; exception.ParameterName.Should().Be(parameterName); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("The specified fieldset is invalid."); error.Detail.Should().Be($"{errorMessage} {parameterValueSource}"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be(parameterName); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/ResourceDefinitions/CreateSortExpressionFromLambdaTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/ResourceDefinitions/CreateSortExpressionFromLambdaTests.cs index 607073d7e2..dc59dbe907 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/ResourceDefinitions/CreateSortExpressionFromLambdaTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/ResourceDefinitions/CreateSortExpressionFromLambdaTests.cs @@ -8,7 +8,6 @@ using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; using Microsoft.Extensions.Logging.Abstractions; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.ResourceDefinitions; @@ -120,7 +119,7 @@ public void Cannot_convert_unexposed_attribute() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().StartWith("The lambda expression 'file => Convert(file.IsCompressed, Object)' is invalid. "); @@ -142,7 +141,7 @@ public void Cannot_convert_unexposed_ToMany_relationship() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().StartWith("The lambda expression 'file => Convert(file.Content.Length, Object)' is invalid. "); @@ -164,7 +163,7 @@ public void Cannot_convert_unexposed_ToOne_relationship() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().StartWith("The lambda expression 'file => file.ParentDirectory.Name' is invalid. "); @@ -186,7 +185,7 @@ public void Cannot_convert_unexposed_resource_type() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().StartWith("The lambda expression 'entry => Convert(entry, FileEntry).Content' is invalid. "); @@ -208,7 +207,7 @@ public void Cannot_convert_count_with_predicate() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().StartWith("The lambda expression 'directory => Convert(directory.Files.Count(_ => True), Object)' is invalid. "); @@ -230,7 +229,7 @@ public void Cannot_convert_null_selector() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().Be("The lambda expression '_ => null' is invalid. Unsupported expression body 'null'."); @@ -251,7 +250,7 @@ public void Cannot_convert_self_selector() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().Be("The lambda expression 'entry => entry' is invalid. Unsupported expression body 'entry'."); @@ -273,7 +272,7 @@ public void Cannot_convert_conditional_operator() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().Match("The lambda expression '*' is invalid. Unsupported expression body '*'."); @@ -294,7 +293,7 @@ public void Cannot_convert_concatenation_operator() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().Match("The lambda expression '*' is invalid. Unsupported expression body '*'."); @@ -321,7 +320,7 @@ public void Cannot_convert_projection_into_anonymous_type() // Assert JsonApiException exception = action.Should().ThrowExactly().Which; - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); exception.Errors[0].StatusCode.Should().Be(HttpStatusCode.InternalServerError); exception.Errors[0].Title.Should().StartWith("Invalid lambda expression for sorting from resource definition. It should "); exception.Errors[0].Detail.Should().Match("The lambda expression '*' is invalid. Unsupported expression body '*'."); diff --git a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/HasManyAttributeTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/HasManyAttributeTests.cs index 06339cf293..4a9d05f4dc 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/HasManyAttributeTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/HasManyAttributeTests.cs @@ -1,7 +1,6 @@ using FluentAssertions; using JsonApiDotNetCore.Resources; using JsonApiDotNetCore.Resources.Annotations; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.ResourceGraph; @@ -79,7 +78,7 @@ public void Can_set_value_to_collection_with_single_resource() attribute.SetValue(resource, children); // Assert - attribute.GetValue(resource).Should().BeOfType>().Subject.ShouldHaveCount(1); + attribute.GetValue(resource).Should().BeOfType>().Subject.Should().HaveCount(1); } [Fact] @@ -154,7 +153,7 @@ public void Can_add_value_to_List() // Assert List collection = attribute.GetValue(resource).Should().BeOfType>().Subject!; - collection.ShouldHaveCount(2); + collection.Should().HaveCount(2); } [Fact] @@ -181,7 +180,7 @@ public void Can_add_existing_value_to_List() // Assert List collection = attribute.GetValue(resource).Should().BeOfType>().Subject!; - collection.ShouldHaveCount(1); + collection.Should().HaveCount(1); } [Fact] @@ -208,7 +207,7 @@ public void Can_add_value_to_HashSet() // Assert HashSet collection = attribute.GetValue(resource).Should().BeOfType>().Subject!; - collection.ShouldHaveCount(2); + collection.Should().HaveCount(2); } [Fact] @@ -235,7 +234,7 @@ public void Can_add_existing_value_to_HashSet() // Assert HashSet collection = attribute.GetValue(resource).Should().BeOfType>().Subject!; - collection.ShouldHaveCount(1); + collection.Should().HaveCount(1); } [Fact] @@ -259,7 +258,7 @@ public void Can_add_value_to_null_collection() // Assert HashSet collection = attribute.GetValue(resource).Should().BeOfType>().Subject!; - collection.ShouldHaveCount(1); + collection.Should().HaveCount(1); } public sealed class TestResource : Identifiable diff --git a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs index de7ac84d1b..8288595662 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs @@ -265,7 +265,7 @@ public void Logs_warning_when_adding_non_resource_type() // Assert IReadOnlyList logLines = loggerProvider.GetLines(); - logLines.ShouldHaveCount(1); + logLines.Should().HaveCount(1); logLines[0].Should().Be( $"[WARNING] Skipping: Type '{typeof(NonResource)}' does not implement 'IIdentifiable'. Add [NoResource] to suppress this warning."); @@ -302,7 +302,7 @@ public void Logs_warning_when_adding_resource_without_attributes() // Assert IReadOnlyList logLines = loggerProvider.GetLines(); - logLines.ShouldHaveCount(1); + logLines.Should().HaveCount(1); logLines[0].Should().Be($"[WARNING] Type '{typeof(ResourceWithHasOneRelationship)}' does not contain any attributes."); } @@ -321,7 +321,7 @@ public void Logs_warning_on_empty_graph() // Assert IReadOnlyList logLines = loggerProvider.GetLines(); - logLines.ShouldHaveCount(1); + logLines.Should().HaveCount(1); logLines[0].Should().Be("[WARNING] The resource graph is empty."); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/ResourceObjectConverterTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/ResourceObjectConverterTests.cs index d5a63c0447..2b0557bcdf 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/ResourceObjectConverterTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/ResourceObjectConverterTests.cs @@ -55,13 +55,13 @@ public void Permits_request_body_without_extension_usage() ResourceObject resourceObject = testContext.Converter.Read(ref reader, typeof(ResourceObject), testContext.SerializerReadOptions); // Assert - resourceObject.Attributes.ShouldContainKey("baseValue").Should().Be("baseAttribute"); - resourceObject.Attributes.ShouldContainKey("derivedValue").Should().Be("derivedAttribute"); + resourceObject.Attributes.Should().ContainKey("baseValue").WhoseValue.Should().Be("baseAttribute"); + resourceObject.Attributes.Should().ContainKey("derivedValue").WhoseValue.Should().Be("derivedAttribute"); - resourceObject.Relationships.ShouldContainKey("parent").With(value => + resourceObject.Relationships.Should().ContainKey("parent").WhoseValue.With(value => { - value.ShouldNotBeNull(); - value.Data.SingleValue.ShouldNotBeNull(); + value.Should().NotBeNull(); + value.Data.SingleValue.Should().NotBeNull(); value.Data.SingleValue.Type.Should().Be("baseTypes"); value.Data.SingleValue.Id.Should().Be("1"); }); @@ -159,8 +159,8 @@ public void Permits_request_body_with_extension_when_extension_enabled() ResourceObject resourceObject = testContext.Converter.Read(ref reader, typeof(ResourceObject), testContext.SerializerReadOptions); // Assert - resourceObject.Attributes.ShouldNotBeNull(); - resourceObject.Relationships.ShouldNotBeNull(); + resourceObject.Attributes.Should().NotBeNull(); + resourceObject.Relationships.Should().NotBeNull(); } [Fact] @@ -191,12 +191,12 @@ public void Throws_for_request_body_with_extension_in_attributes_when_extension_ JsonApiException? exception = action.Should().ThrowExactly().WithInnerExceptionExactly().Which; exception.StackTrace.Should().Contain(nameof(ExtensionAwareResourceObjectConverter)); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Failure requested from attributes."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("attributes/type-info:fail"); } @@ -232,12 +232,12 @@ public void Throws_for_request_body_with_extension_in_relationships_when_extensi JsonApiException? exception = action.Should().ThrowExactly().WithInnerExceptionExactly().Which; exception.StackTrace.Should().Contain(nameof(ExtensionAwareResourceObjectConverter)); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.BadRequest); error.Title.Should().Be("Failure requested from relationships."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("relationships/type-info:fail"); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/SourcePointerInExceptionTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/SourcePointerInExceptionTests.cs index 9216b4b896..1638c0b0d2 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/SourcePointerInExceptionTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Extensions/SourcePointerInExceptionTests.cs @@ -10,7 +10,6 @@ using JsonApiDotNetCore.Serialization.Request; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging.Abstractions; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.Serialization.Extensions; @@ -47,12 +46,12 @@ public async Task Adds_source_pointer_to_JsonApiException_thrown_from_JsonConver JsonApiException? exception = (await action.Should().ThrowExactlyAsync()).Which; exception.StackTrace.Should().Contain(nameof(ThrowingResourceObjectConverter)); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Extension error"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); } @@ -75,12 +74,12 @@ public async Task Makes_source_pointer_absolute_in_JsonApiException_thrown_from_ JsonApiException? exception = (await action.Should().ThrowExactlyAsync()).Which; exception.StackTrace.Should().Contain(nameof(ThrowingResourceObjectConverter)); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Extension error"); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relative/path"); } diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/InputConversionTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/InputConversionTests.cs index 68b49ef7b8..a7bc52ee4b 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/InputConversionTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/InputConversionTests.cs @@ -10,7 +10,6 @@ using JsonApiDotNetCore.Serialization.Objects; using JsonApiDotNetCore.Serialization.Request.Adapters; using Microsoft.Extensions.Logging.Abstractions; -using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.UnitTests.Serialization; @@ -109,7 +108,7 @@ public void Converts_various_data_types_with_values() var model = (ResourceWithVariousDataTypes?)documentAdapter.Convert(document); // Assert - model.ShouldNotBeNull(); + model.Should().NotBeNull(); model.Boolean.Should().Be(booleanValue); model.NullableBoolean.Should().Be(nullableBooleanValue); @@ -134,10 +133,10 @@ public void Converts_various_data_types_with_values() model.Enum.Should().Be(enumValue); model.NullableEnum.Should().Be(nullableEnumValue); - model.ComplexObject.ShouldNotBeNull(); + model.ComplexObject.Should().NotBeNull(); model.ComplexObject.Value.Should().Be(complexObject.Value); - model.ComplexObjectList.ShouldHaveCount(2); + model.ComplexObjectList.Should().HaveCount(2); model.ComplexObjectList[0].Value.Should().Be(complexObjectList[0].Value); model.ComplexObjectList[1].Value.Should().Be(complexObjectList[1].Value); } @@ -215,7 +214,7 @@ public void Converts_various_data_types_with_defaults() var model = (ResourceWithVariousDataTypes?)documentAdapter.Convert(document); // Assert - model.ShouldNotBeNull(); + model.Should().NotBeNull(); model.Boolean.Should().Be(booleanValue); model.NullableBoolean.Should().Be(nullableBooleanValue); diff --git a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs index 032bcd7c1f..89de6ba3e8 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/Serialization/Response/ResponseModelAdapterTests.cs @@ -565,9 +565,9 @@ public void Duplicate_children_in_multiple_chains_occur_once_in_output() Document document = responseModelAdapter.Convert(articles); // Assert - document.Included.ShouldHaveCount(1); + document.Included.Should().HaveCount(1); - document.Included[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be(person.Name)); + document.Included[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be(person.Name); document.Included[0].Id.Should().Be(person.StringId); } diff --git a/test/MultiDbContextTests/ResourceTests.cs b/test/MultiDbContextTests/ResourceTests.cs index 3b2c259c57..a648f75cfc 100644 --- a/test/MultiDbContextTests/ResourceTests.cs +++ b/test/MultiDbContextTests/ResourceTests.cs @@ -35,8 +35,8 @@ public async Task Can_get_ResourceAs() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("nameA").With(value => value.Should().Be("SampleA")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("nameA").WhoseValue.Should().Be("SampleA"); } [Fact] @@ -51,8 +51,8 @@ public async Task Can_get_ResourceBs() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("nameB").With(value => value.Should().Be("SampleB")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("nameB").WhoseValue.Should().Be("SampleB"); } protected override HttpClient CreateClient() diff --git a/test/NoEntityFrameworkTests/PersonTests.cs b/test/NoEntityFrameworkTests/PersonTests.cs index 01cdefa3e5..c450239429 100644 --- a/test/NoEntityFrameworkTests/PersonTests.cs +++ b/test/NoEntityFrameworkTests/PersonTests.cs @@ -35,7 +35,7 @@ public async Task Can_get_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Meta.Should().ContainTotal(2); } @@ -52,8 +52,8 @@ public async Task Can_filter_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be("Jane")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be("Jane"); responseDocument.Meta.Should().ContainTotal(1); } @@ -70,8 +70,8 @@ public async Task Can_filter_in_related_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be("John")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be("John"); responseDocument.Meta.Should().ContainTotal(1); } @@ -88,7 +88,7 @@ public async Task Can_sort_on_attribute_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be("2"); responseDocument.Data.ManyValue[1].Id.Should().Be("1"); } @@ -105,7 +105,7 @@ public async Task Can_sort_on_count_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); + responseDocument.Data.ManyValue.Should().HaveCount(2); responseDocument.Data.ManyValue[0].Id.Should().Be("1"); responseDocument.Data.ManyValue[1].Id.Should().Be("2"); } @@ -122,8 +122,8 @@ public async Task Can_paginate_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("firstName").With(value => value.Should().Be("Jane")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be("Jane"); responseDocument.Meta.Should().ContainTotal(2); } @@ -140,8 +140,8 @@ public async Task Can_select_fields_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldNotBeEmpty(); - responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Attributes.ShouldOnlyContainKeys("lastName", "displayName")); + responseDocument.Data.ManyValue.Should().NotBeEmpty(); + responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Attributes.Should().OnlyContainKeys("lastName", "displayName")); } [Fact] @@ -172,7 +172,7 @@ public async Task Can_get_primary_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("1"); } @@ -188,9 +188,9 @@ public async Task Can_get_secondary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Make homework")); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Check emails")); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Make homework"); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Check emails"); responseDocument.Meta.Should().ContainTotal(2); } @@ -207,7 +207,7 @@ public async Task Can_get_ToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be("1"); responseDocument.Meta.Should().ContainTotal(1); diff --git a/test/NoEntityFrameworkTests/TagTests.cs b/test/NoEntityFrameworkTests/TagTests.cs index 49b5887adb..9bcb719771 100644 --- a/test/NoEntityFrameworkTests/TagTests.cs +++ b/test/NoEntityFrameworkTests/TagTests.cs @@ -35,7 +35,7 @@ public async Task Can_get_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Meta.Should().ContainTotal(3); } @@ -52,8 +52,8 @@ public async Task Can_filter_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be("Personal")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be("Personal"); responseDocument.Meta.Should().ContainTotal(1); } @@ -70,8 +70,8 @@ public async Task Can_filter_in_related_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be("Business")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be("Business"); responseDocument.Meta.Should().ContainTotal(1); } @@ -88,7 +88,7 @@ public async Task Can_sort_on_attribute_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be("3"); responseDocument.Data.ManyValue[1].Id.Should().Be("2"); responseDocument.Data.ManyValue[2].Id.Should().Be("1"); @@ -106,7 +106,7 @@ public async Task Can_sort_on_count_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Data.ManyValue[0].Id.Should().Be("1"); responseDocument.Data.ManyValue[1].Id.Should().Be("2"); responseDocument.Data.ManyValue[2].Id.Should().Be("3"); @@ -124,8 +124,8 @@ public async Task Can_paginate_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be("Family")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be("Family"); responseDocument.Meta.Should().ContainTotal(3); } @@ -142,9 +142,9 @@ public async Task Can_select_fields_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldNotBeEmpty(); + responseDocument.Data.ManyValue.Should().NotBeEmpty(); responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Attributes.Should().BeNull()); - responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Relationships.ShouldOnlyContainKeys("todoItems")); + responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Relationships.Should().OnlyContainKeys("todoItems")); } [Fact] @@ -175,7 +175,7 @@ public async Task Can_get_primary_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("1"); } @@ -191,10 +191,10 @@ public async Task Can_get_secondary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Make homework")); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Book vacation")); - responseDocument.Data.ManyValue[2].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Cook dinner")); + responseDocument.Data.ManyValue.Should().HaveCount(3); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Make homework"); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Book vacation"); + responseDocument.Data.ManyValue[2].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Cook dinner"); responseDocument.Meta.Should().ContainTotal(3); } @@ -211,7 +211,7 @@ public async Task Can_get_ToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be("3"); responseDocument.Meta.Should().ContainTotal(1); diff --git a/test/NoEntityFrameworkTests/TodoItemTests.cs b/test/NoEntityFrameworkTests/TodoItemTests.cs index 90691fd770..1e691c9cd8 100644 --- a/test/NoEntityFrameworkTests/TodoItemTests.cs +++ b/test/NoEntityFrameworkTests/TodoItemTests.cs @@ -35,7 +35,7 @@ public async Task Can_get_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Meta.Should().ContainTotal(4); } @@ -52,8 +52,8 @@ public async Task Can_filter_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("priority").With(value => value.Should().Be(TodoItemPriority.High)); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("priority").WhoseValue.Should().Be(TodoItemPriority.High); responseDocument.Meta.Should().ContainTotal(1); } @@ -70,7 +70,7 @@ public async Task Can_filter_in_related_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(3); + responseDocument.Data.ManyValue.Should().HaveCount(3); responseDocument.Meta.Should().ContainTotal(3); } @@ -87,7 +87,7 @@ public async Task Can_sort_on_attribute_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue[0].Id.Should().Be("4"); responseDocument.Data.ManyValue[1].Id.Should().Be("3"); responseDocument.Data.ManyValue[2].Id.Should().Be("2"); @@ -106,7 +106,7 @@ public async Task Can_sort_on_count_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(4); + responseDocument.Data.ManyValue.Should().HaveCount(4); responseDocument.Data.ManyValue[0].Id.Should().Be("2"); } @@ -122,8 +122,8 @@ public async Task Can_paginate_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("description").With(value => value.Should().Be("Check emails")); + responseDocument.Data.ManyValue.Should().HaveCount(1); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("description").WhoseValue.Should().Be("Check emails"); responseDocument.Meta.Should().ContainTotal(4); } @@ -140,8 +140,8 @@ public async Task Can_select_fields_in_primary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldNotBeEmpty(); - responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Attributes.ShouldOnlyContainKeys("description", "priority")); + responseDocument.Data.ManyValue.Should().NotBeEmpty(); + responseDocument.Data.ManyValue.Should().AllSatisfy(resource => resource.Attributes.Should().OnlyContainKeys("description", "priority")); } [Fact] @@ -172,7 +172,7 @@ public async Task Can_get_primary_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be("1"); } @@ -188,7 +188,7 @@ public async Task Cannot_get_primary_resource_for_unknown_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -208,9 +208,9 @@ public async Task Can_get_secondary_resources() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(2); - responseDocument.Data.ManyValue[0].Attributes.ShouldContainKey("name").With(value => value.Should().Be("Personal")); - responseDocument.Data.ManyValue[1].Attributes.ShouldContainKey("name").With(value => value.Should().Be("Family")); + responseDocument.Data.ManyValue.Should().HaveCount(2); + responseDocument.Data.ManyValue[0].Attributes.Should().ContainKey("name").WhoseValue.Should().Be("Personal"); + responseDocument.Data.ManyValue[1].Attributes.Should().ContainKey("name").WhoseValue.Should().Be("Family"); responseDocument.Meta.Should().ContainTotal(2); } @@ -227,9 +227,9 @@ public async Task Can_get_secondary_resource() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); - responseDocument.Data.SingleValue.Attributes.ShouldContainKey("firstName").With(value => value.Should().Be("Jane")); + responseDocument.Data.SingleValue.Attributes.Should().ContainKey("firstName").WhoseValue.Should().Be("Jane"); } [Fact] @@ -244,7 +244,7 @@ public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -279,7 +279,7 @@ public async Task Cannot_get_secondary_resource_for_unknown_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.NotFound); - responseDocument.Errors.ShouldHaveCount(1); + responseDocument.Errors.Should().HaveCount(1); ErrorObject error = responseDocument.Errors[0]; error.StatusCode.Should().Be(HttpStatusCode.NotFound); @@ -299,7 +299,7 @@ public async Task Can_get_ToOne_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.SingleValue.ShouldNotBeNull(); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Type.Should().Be("people"); responseDocument.Data.SingleValue.Id.Should().Be("2"); } @@ -331,7 +331,7 @@ public async Task Can_get_ToMany_relationship() // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.ShouldHaveCount(1); + responseDocument.Data.ManyValue.Should().HaveCount(1); responseDocument.Data.ManyValue[0].Id.Should().Be("3"); responseDocument.Meta.Should().ContainTotal(1); diff --git a/test/TestBuildingBlocks/FluentAssertionsExtensions.cs b/test/TestBuildingBlocks/FluentAssertionsExtensions.cs new file mode 100644 index 0000000000..79e1ef7582 --- /dev/null +++ b/test/TestBuildingBlocks/FluentAssertionsExtensions.cs @@ -0,0 +1,49 @@ +using FluentAssertions; +using FluentAssertions.Collections; +using FluentAssertions.Primitives; +using JetBrains.Annotations; +using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; + +// ReSharper disable UnusedMethodReturnValue.Global + +namespace TestBuildingBlocks; + +public static class FluentAssertionsExtensions +{ + // Workaround for source.Should().NotBeNull().And.Subject having declared type 'object'. + [System.Diagnostics.Contracts.Pure] + public static StrongReferenceTypeAssertions RefShould([SysNotNull] this T? actualValue) + where T : class + { + actualValue.Should().NotBeNull(); + return new StrongReferenceTypeAssertions(actualValue); + } + + public static AndConstraint OnlyContainKeys( + this GenericDictionaryAssertions source, params TKey[] expected) + where TCollection : IEnumerable> + where TAssertions : GenericDictionaryAssertions + { + return source.HaveCount(expected.Length).And.ContainKeys(expected); + } + + // Workaround for CS0854: An expression tree may not contain a call or invocation that uses optional arguments. + public static WhoseValueConstraint ContainKey2( + this GenericDictionaryAssertions source, TKey expected) + where TCollection : IEnumerable> + where TAssertions : GenericDictionaryAssertions + { + return source.ContainKey(expected); + } + + public static void With(this T subject, [InstantHandle] Action continuation) + { + continuation(subject); + } + + public sealed class StrongReferenceTypeAssertions(TReference subject) + : ReferenceTypeAssertions>(subject) + { + protected override string Identifier => "subject"; + } +} diff --git a/test/TestBuildingBlocks/NullabilityAssertionExtensions.cs b/test/TestBuildingBlocks/NullabilityAssertionExtensions.cs deleted file mode 100644 index 0627449664..0000000000 --- a/test/TestBuildingBlocks/NullabilityAssertionExtensions.cs +++ /dev/null @@ -1,62 +0,0 @@ -using FluentAssertions; -using JetBrains.Annotations; -using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; - -// ReSharper disable PossibleMultipleEnumeration -#pragma warning disable CS8777 // Parameter must have a non-null value when exiting. - -namespace TestBuildingBlocks; - -public static class NullabilityAssertionExtensions -{ - [CustomAssertion] - public static T ShouldNotBeNull([SysNotNull] this T? subject) - { - subject.Should().NotBeNull(); - return subject!; - } - - [CustomAssertion] - public static void ShouldNotBeEmpty([SysNotNull] this string? subject) - { - subject.Should().NotBeEmpty(); - } - - [CustomAssertion] - public static void ShouldNotBeEmpty([SysNotNull] this IEnumerable? subject) - { - subject.Should().NotBeEmpty(); - } - - [CustomAssertion] - public static void ShouldNotBeNullOrEmpty([SysNotNull] this string? subject) - { - subject.Should().NotBeNullOrEmpty(); - } - - [CustomAssertion] - public static void ShouldHaveCount([SysNotNull] this IEnumerable? subject, int expected) - { - subject.Should().HaveCount(expected); - } - - [CustomAssertion] - public static TValue? ShouldContainKey([SysNotNull] this IDictionary? subject, TKey expected) - { - subject.Should().ContainKey(expected); - - return subject![expected]; - } - - [CustomAssertion] - public static void ShouldOnlyContainKeys([SysNotNull] this IDictionary? subject, params TKey[] expected) - { - subject.Should().HaveCount(expected.Length); - subject.Should().ContainKeys(expected); - } - - public static void With(this T subject, [InstantHandle] Action continuation) - { - continuation(subject); - } -} diff --git a/test/UnitTests/Graph/ResourceDescriptorAssemblyCacheTests.cs b/test/UnitTests/Graph/ResourceDescriptorAssemblyCacheTests.cs index 8f30b584e4..0531c42b1a 100644 --- a/test/UnitTests/Graph/ResourceDescriptorAssemblyCacheTests.cs +++ b/test/UnitTests/Graph/ResourceDescriptorAssemblyCacheTests.cs @@ -1,7 +1,6 @@ using FluentAssertions; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Resources; -using TestBuildingBlocks; using Xunit; namespace UnitTests.Graph; @@ -21,7 +20,7 @@ public void GetResourceDescriptorsPerAssembly_Locates_Identifiable_Resource() IReadOnlyCollection descriptors = assemblyCache.GetResourceDescriptors(); // Assert - descriptors.ShouldNotBeEmpty(); + descriptors.Should().NotBeEmpty(); descriptors.Should().ContainSingle(descriptor => descriptor.ResourceClrType == resourceClrType); } @@ -38,7 +37,7 @@ public void GetResourceDescriptorsPerAssembly_Only_Contains_IIdentifiable_Types( IReadOnlyCollection descriptors = assemblyCache.GetResourceDescriptors(); // Assert - descriptors.ShouldNotBeEmpty(); + descriptors.Should().NotBeEmpty(); descriptors.Select(descriptor => descriptor.ResourceClrType).Should().AllBeAssignableTo(); } } diff --git a/test/UnitTests/Graph/TypeLocatorTests.cs b/test/UnitTests/Graph/TypeLocatorTests.cs index b5023e87ba..2731dcba0a 100644 --- a/test/UnitTests/Graph/TypeLocatorTests.cs +++ b/test/UnitTests/Graph/TypeLocatorTests.cs @@ -1,7 +1,6 @@ using System.Reflection; using FluentAssertions; using JsonApiDotNetCore.Configuration; -using TestBuildingBlocks; using Xunit; namespace UnitTests.Graph; @@ -22,7 +21,7 @@ public void GetContainerRegistrationFromAssembly_Gets_Implementation() (Type implementationType, Type serviceInterface)? result = typeLocator.GetContainerRegistrationFromAssembly(assembly, unboundInterface, typeArgument); // Assert - result.ShouldNotBeNull(); + result.Should().NotBeNull(); result.Value.implementationType.Should().Be(); result.Value.serviceInterface.Should().Be>(); } @@ -69,7 +68,7 @@ public void ResolveResourceDescriptor_Returns_Type_If_Type_Is_IIdentifiable() ResourceDescriptor? descriptor = typeLocator.ResolveResourceDescriptor(resourceClrType); // Assert - descriptor.ShouldNotBeNull(); + descriptor.Should().NotBeNull(); descriptor.ResourceClrType.Should().Be(resourceClrType); descriptor.IdClrType.Should().Be(); } diff --git a/test/UnitTests/Models/ResourceConstructionExpressionTests.cs b/test/UnitTests/Models/ResourceConstructionExpressionTests.cs index d8345b5de3..48e43d2452 100644 --- a/test/UnitTests/Models/ResourceConstructionExpressionTests.cs +++ b/test/UnitTests/Models/ResourceConstructionExpressionTests.cs @@ -3,7 +3,6 @@ using FluentAssertions; using JetBrains.Annotations; using JsonApiDotNetCore.Resources; -using TestBuildingBlocks; using Xunit; namespace UnitTests.Models; @@ -24,7 +23,7 @@ public void When_resource_has_default_constructor_it_must_succeed() Func createFunction = Expression.Lambda>(newExpression).Compile(); ResourceWithoutConstructor resource = createFunction(); - resource.ShouldNotBeNull(); + resource.Should().NotBeNull(); } [Fact] From 520e5a05f5e7d4e3d034122a8a3794112bb84e3a Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 13:03:24 +0100 Subject: [PATCH 3/9] Remove redundant suppressions --- test/TestBuildingBlocks/JsonElementAssertionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs b/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs index f4df8938dd..1526bcdade 100644 --- a/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs +++ b/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs @@ -32,7 +32,7 @@ public static string GetSchemaReferenceId(this JsonElement source) string? jsonElementValue = source.GetString(); jsonElementValue.Should().StartWith(ComponentSchemaPrefix); - return jsonElementValue![ComponentSchemaPrefix.Length..]; + return jsonElementValue[ComponentSchemaPrefix.Length..]; } [CustomAssertion] From 5a34ed3c59a8628b8279f02146280a4df2ed5d78 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 12:41:00 +0100 Subject: [PATCH 4/9] Remove usages of ShouldHaveCount --- .../AtomicCreateResourceTests.cs | 4 +- .../AtomicOperations/AtomicLocalIdTests.cs | 2 +- .../AtomicRelationshipTests.cs | 6 +- .../AtomicUpdateResourceTests.cs | 6 +- .../ClientIdGenerationModesTests.cs | 4 +- .../Headers/ETagTests.cs | 10 +-- .../Headers/HeaderTests.cs | 10 +-- .../ModelStateValidationTests.cs | 28 +++---- .../QueryStrings/FilterTests.cs | 8 +- .../QueryStrings/IncludeTests.cs | 12 +-- .../QueryStrings/PaginationTests.cs | 10 +-- .../QueryStrings/SortTests.cs | 8 +- .../QueryStrings/SparseFieldSetTests.cs | 4 +- .../CreateResourceTests.cs | 8 +- .../DeleteResourceTests.cs | 2 +- .../FetchRelationshipTests.cs | 6 +- .../FetchResourceTests.cs | 10 +-- .../UpdateRelationshipTests.cs | 2 +- .../UpdateResourceTests.cs | 4 +- .../LegacyOpenApi/ResponseTests.cs | 2 +- .../AtomicCreateResourceTests.cs | 4 +- .../AtomicOperations/AtomicLocalIdTests.cs | 2 +- .../AtomicRelationshipTests.cs | 6 +- .../AtomicUpdateResourceTests.cs | 6 +- .../ClientIdGenerationModesTests.cs | 4 +- .../Headers/ETagTests.cs | 10 +-- .../Headers/HeaderTests.cs | 10 +-- .../ModelStateValidationTests.cs | 26 +++--- .../QueryStrings/FilterTests.cs | 8 +- .../QueryStrings/IncludeTests.cs | 12 +-- .../QueryStrings/PaginationTests.cs | 10 +-- .../QueryStrings/SortTests.cs | 8 +- .../QueryStrings/SparseFieldSetTests.cs | 4 +- .../CreateResourceTests.cs | 8 +- .../DeleteResourceTests.cs | 2 +- .../FetchRelationshipTests.cs | 6 +- .../FetchResourceTests.cs | 10 +-- .../UpdateRelationshipTests.cs | 2 +- .../UpdateResourceTests.cs | 4 +- .../Documentation/DocumentationTests.cs | 79 ++++++++++--------- .../Documentation/ErrorResponseTests.cs | 42 +++++----- .../Links/Disabled/LinksDisabledTests.cs | 2 +- 42 files changed, 206 insertions(+), 205 deletions(-) diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs index e36fcf1a58..baf0939624 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs @@ -63,7 +63,7 @@ public async Task Can_create_resource_with_attributes() // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(1); + response.AtomicResults.Should().HaveCount(1); TeacherDataInResponse teacherDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; teacherDataInResponse.Attributes.ShouldNotBeNull(); @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(1); + response.AtomicResults.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Attributes.ShouldNotBeNull(); diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs index 1f0bb873d3..61828a60a3 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs @@ -174,7 +174,7 @@ public async Task Can_use_local_IDs() // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(7); + response.AtomicResults.Should().HaveCount(7); TeacherDataInResponse teacherInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; teacherInResponse.Attributes.ShouldNotBeNull(); diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs index 34b8ee8807..2915a80f92 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(2); + teacherInDatabase.Teaches.Should().HaveCount(2); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(1).Id); }); @@ -206,7 +206,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(3); + teacherInDatabase.Teaches.Should().HaveCount(3); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingTeacher.Teaches.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(1).Id); @@ -269,7 +269,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(1); + teacherInDatabase.Teaches.Should().HaveCount(1); teacherInDatabase.Teaches.ElementAt(0).Id.Should().Be(existingTeacher.Teaches.ElementAt(1).Id); }); } diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs index 83a40dd3de..47b682b943 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs @@ -77,7 +77,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(1); + response.AtomicResults.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); @@ -141,7 +141,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(1); + response.AtomicResults.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); @@ -224,7 +224,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.AtomicResults.ShouldHaveCount(1); + response.AtomicResults.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Id.Should().Be(existingEnrollment.StringId); diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 9ae8433d83..ce17a1d366 100644 --- a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -57,7 +57,7 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.Status.Should().Be("422"); @@ -219,7 +219,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.Conflict); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("409"); diff --git a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs index e148256fe1..1b7102523c 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs @@ -54,7 +54,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); } @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.ShouldNotBeNull(); string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); } @@ -111,7 +111,7 @@ public async Task Returns_no_ETag_for_failed_GET_request() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); @@ -197,7 +197,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotModified); string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Be(responseETag); } @@ -233,7 +233,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.ShouldNotBeNull(); string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); } diff --git a/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs index cbec4b10ff..7e56f5ecb5 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs @@ -62,7 +62,7 @@ public async Task Returns_Location_for_post_resource_request() response.Data.ShouldNotBeNull(); string[] locationHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); - locationHeaderValues.ShouldHaveCount(1); + locationHeaderValues.Should().HaveCount(1); locationHeaderValues[0].Should().Be($"/countries/{response.Data.Id}"); } @@ -92,7 +92,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -121,7 +121,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -151,7 +151,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -181,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert string[] contentLengthHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } diff --git a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index 860ed64a3a..667a4e2f8e 100644 --- a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -60,7 +60,7 @@ public async Task Cannot_exceed_length_constraint(string firstName) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -98,7 +98,7 @@ public async Task Cannot_exceed_string_length_constraint(string userName) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -134,7 +134,7 @@ public async Task Cannot_violate_regular_expression_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -170,7 +170,7 @@ public async Task Cannot_use_invalid_credit_card_number() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -206,7 +206,7 @@ public async Task Cannot_use_invalid_email_address() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -243,7 +243,7 @@ public async Task Cannot_exceed_min_length_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); const int minCharsInBase64 = SocialMediaAccount.MinPasswordCharsInBase64; @@ -281,7 +281,7 @@ public async Task Cannot_exceed_max_length_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); const int maxCharsInBase64 = SocialMediaAccount.MaxPasswordCharsInBase64; @@ -319,7 +319,7 @@ public async Task Cannot_use_invalid_base64() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -359,7 +359,7 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -395,7 +395,7 @@ public async Task Cannot_use_relative_url() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -433,7 +433,7 @@ public async Task Cannot_exceed_collection_length_constraint(int length) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -469,7 +469,7 @@ public async Task Cannot_use_non_allowed_value() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -505,7 +505,7 @@ public async Task Cannot_use_denied_value() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -541,7 +541,7 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync()).Which; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs index 07b1b5a085..6459508407 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs @@ -55,7 +55,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -100,7 +100,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -145,7 +145,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); @@ -177,7 +177,7 @@ public async Task Cannot_use_empty_filter() exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); exception.Links.ShouldNotBeNull(); exception.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors[0]; error.Status.Should().Be("400"); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs index d55cf95457..0984487614 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs @@ -54,10 +54,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values.ElementAt(0).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values.ElementAt(1).StringId); } @@ -96,7 +96,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ShouldNotBeNull(); response.Data.Id.Should().Be(node.StringId); - response.Included.ShouldHaveCount(3); + response.Included.Should().HaveCount(3); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Children.ElementAt(0).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Children.ElementAt(1).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values[0].StringId); @@ -133,9 +133,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(include => include.Id == node.StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Parent.StringId); } @@ -174,7 +174,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ShouldNotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); - response.Included.ShouldHaveCount(1); + response.Included.Should().HaveCount(1); response.Included.OfType().Should().ContainSingle(nodeData => nodeData.Id == node.Parent.Parent.StringId).Subject.With( nodeData => diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs index ce1f7ff1fe..8b835840ea 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs @@ -54,7 +54,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Meta.ShouldNotBeNull(); response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -91,7 +91,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); @@ -129,7 +129,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); response.Meta.ShouldNotBeNull(); response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -157,7 +157,7 @@ public async Task Cannot_use_empty_page_size() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("400"); @@ -189,7 +189,7 @@ public async Task Cannot_use_empty_page_number() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("400"); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs index 3cc562a662..7fa03f8b09 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs @@ -55,7 +55,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(1).Id.Should().Be(nodes[0].StringId); } @@ -92,7 +92,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(0).StringId); } @@ -129,7 +129,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); } @@ -156,7 +156,7 @@ public async Task Cannot_use_empty_sort() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("400"); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 83229492b0..2a61043a40 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -53,7 +53,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -133,7 +133,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs index f3f95e48ca..248c347966 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -104,10 +104,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); response.Data.Relationships.AudioStreams.ShouldNotBeNull(); - response.Data.Relationships.AudioStreams.Data.ShouldHaveCount(1); + response.Data.Relationships.AudioStreams.Data.Should().HaveCount(1); response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId).Subject .With(streamData => @@ -145,7 +145,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.VideoStream.ShouldNotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); - channelInDatabase.AudioStreams.ShouldHaveCount(1); + channelInDatabase.AudioStreams.Should().HaveCount(1); channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); }); } @@ -208,7 +208,7 @@ public async Task Cannot_create_resource_with_unknown_relationship_ID() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs index 6c2f00ef03..c19672be0b 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/DeleteResourceTests.cs @@ -70,7 +70,7 @@ public async Task Cannot_delete_unknown_resource() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs index 979c6ab270..ed51c31362 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -98,7 +98,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); } @@ -124,7 +124,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(0); + response.Data.Should().HaveCount(0); } [Fact] @@ -143,7 +143,7 @@ public async Task Cannot_get_relationship_for_unknown_primary_ID() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs index 998daa3376..2cc4c848d8 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -48,7 +48,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); channel1.Attributes.ShouldNotBeNull(); @@ -129,7 +129,7 @@ public async Task Cannot_get_primary_resource_for_unknown_ID() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); @@ -210,7 +210,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); audioStream1.Attributes.ShouldNotBeNull(); @@ -242,7 +242,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Data.ShouldHaveCount(0); + response.Data.Should().HaveCount(0); } [Fact] @@ -261,7 +261,7 @@ public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(1); + exception.Errors.Should().HaveCount(1); ErrorObject error = exception.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs index df9ce1e9d9..c8b5425c5e 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -386,7 +386,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(2); + exception.Errors.Should().HaveCount(2); ErrorObject error1 = exception.Errors.ElementAt(0); error1.Status.Should().Be("404"); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs index 9f2bfd31ff..db365db1f1 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -113,7 +113,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Relationships.AudioStreams.ShouldNotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); - response.Included.ShouldHaveCount(1); + response.Included.Should().HaveCount(1); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -301,7 +301,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Errors.ShouldHaveCount(2); + exception.Errors.Should().HaveCount(2); ErrorObject error1 = exception.Errors.ElementAt(0); error1.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs index a4f3ae140e..ceec38dd03 100644 --- a/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs @@ -229,7 +229,7 @@ public async Task Getting_unknown_resource_translates_error_response() exception.Result.Links.ShouldNotBeNull(); exception.Result.Links.Self.Should().Be("http://localhost/api/flights/ZvuH1"); exception.Result.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject? error = exception.Result.Errors.ElementAt(0); error.Id.Should().Be("f1a520ac-02a0-466b-94ea-86cbaa86f02f"); diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs index 8ff2a49913..632cf06aaa 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs @@ -60,7 +60,7 @@ public async Task Can_create_resource_with_attributes() // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(1); + response.Atomic_results.Should().HaveCount(1); TeacherDataInResponse teacherDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; teacherDataInResponse.Attributes.ShouldNotBeNull(); @@ -135,7 +135,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(1); + response.Atomic_results.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Attributes.ShouldNotBeNull(); diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs index 4f31d5a904..3db0a8d6b7 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs @@ -152,7 +152,7 @@ public async Task Can_use_local_IDs() // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(7); + response.Atomic_results.Should().HaveCount(7); TeacherDataInResponse teacherInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; teacherInResponse.Attributes.ShouldNotBeNull(); diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs index ddac919415..c2c491dfbe 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs @@ -132,7 +132,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(2); + teacherInDatabase.Teaches.Should().HaveCount(2); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(1).Id); }); @@ -191,7 +191,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(3); + teacherInDatabase.Teaches.Should().HaveCount(3); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingTeacher.Teaches.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(0).Id); teacherInDatabase.Teaches.Should().ContainSingle(course => course.Id == existingCourses.ElementAt(1).Id); @@ -249,7 +249,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Teacher teacherInDatabase = await dbContext.Teachers.Include(teacher => teacher.Teaches).FirstWithIdAsync(existingTeacher.Id); - teacherInDatabase.Teaches.ShouldHaveCount(1); + teacherInDatabase.Teaches.Should().HaveCount(1); teacherInDatabase.Teaches.ElementAt(0).Id.Should().Be(existingTeacher.Teaches.ElementAt(1).Id); }); } diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs index 9d1d532e8f..e7d2e56c56 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs @@ -73,7 +73,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(1); + response.Atomic_results.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); @@ -134,7 +134,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(1); + response.Atomic_results.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); @@ -213,7 +213,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.ShouldNotBeNull(); - response.Atomic_results.ShouldHaveCount(1); + response.Atomic_results.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Id.Should().Be(existingEnrollment.StringId); diff --git a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 727b55da95..937f7de153 100644 --- a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -55,7 +55,7 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("422"); @@ -211,7 +211,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.Conflict); exception.Message.Should().Be("HTTP 409: The request body contains conflicting information or another resource with the same ID already exists."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("409"); diff --git a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs index 764faa1f25..fa7f6c4161 100644 --- a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs @@ -48,7 +48,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); } @@ -75,7 +75,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); response.Result.ShouldNotBeNull(); @@ -98,7 +98,7 @@ public async Task Returns_no_ETag_for_failed_GET_request() exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The country does not exist."); exception.Headers.Should().NotContainKey(HeaderNames.ETag); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); @@ -166,7 +166,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response2.StatusCode.Should().Be((int)HttpStatusCode.NotModified); string[] eTagHeaderValues = response2.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Be(responseETag); response2.Result.Should().BeNull(); @@ -196,7 +196,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] eTagHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); - eTagHeaderValues.ShouldHaveCount(1); + eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); response.Result.ShouldNotBeNull(); diff --git a/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs index 6a0366fa81..7057fde4dd 100644 --- a/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs @@ -55,7 +55,7 @@ public async Task Returns_Location_for_post_resource_request() response.Result.ShouldNotBeNull(); string[] locationHeaderValues = response.Headers.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); - locationHeaderValues.ShouldHaveCount(1); + locationHeaderValues.Should().HaveCount(1); locationHeaderValues[0].Should().Be($"/countries/{response.Result.Data.Id}"); } @@ -82,7 +82,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -108,7 +108,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -135,7 +135,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } @@ -162,7 +162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.StatusCode.Should().Be((int)HttpStatusCode.OK); string[] contentLengthHeaderValues = response.Headers.Should().ContainKey(HeaderNames.ContentLength).WhoseValue.ToArray(); - contentLengthHeaderValues.ShouldHaveCount(1); + contentLengthHeaderValues.Should().HaveCount(1); long.Parse(contentLengthHeaderValues[0]).Should().BeGreaterThan(0); } diff --git a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index 7d9587304e..0ac8d07373 100644 --- a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -58,7 +58,7 @@ public async Task Cannot_exceed_length_constraint(string firstName) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -95,7 +95,7 @@ public async Task Cannot_exceed_string_length_constraint(string userName) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -130,7 +130,7 @@ public async Task Cannot_violate_regular_expression_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -165,7 +165,7 @@ public async Task Cannot_use_invalid_credit_card_number() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -200,7 +200,7 @@ public async Task Cannot_use_invalid_email_address() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -236,7 +236,7 @@ public async Task Cannot_exceed_min_length_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); const int minCharsInBase64 = SocialMediaAccount.MinPasswordCharsInBase64; @@ -273,7 +273,7 @@ public async Task Cannot_exceed_max_length_constraint() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); const int maxCharsInBase64 = SocialMediaAccount.MaxPasswordCharsInBase64; @@ -314,7 +314,7 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -349,7 +349,7 @@ public async Task Cannot_use_relative_url() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -386,7 +386,7 @@ public async Task Cannot_exceed_collection_length_constraint(int length) // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -421,7 +421,7 @@ public async Task Cannot_use_non_allowed_value() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -456,7 +456,7 @@ public async Task Cannot_use_denied_value() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); @@ -491,7 +491,7 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() // Assert ErrorResponseDocument document = (await action.Should().ThrowExactlyAsync>()).Which.Result; - document.Errors.ShouldHaveCount(1); + document.Errors.Should().HaveCount(1); ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs index 94078c8b73..87a0432828 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -92,7 +92,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -133,7 +133,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(1)); @@ -162,7 +162,7 @@ public async Task Cannot_use_empty_filter() exception.Message.Should().Be("HTTP 400: The query string is invalid."); exception.Result.Links.ShouldNotBeNull(); exception.Result.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("400"); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs index 9cba66d766..fa799f3f67 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs @@ -49,10 +49,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values.ElementAt(0).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values.ElementAt(1).StringId); } @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Id.Should().Be(node.StringId); - response.Included.ShouldHaveCount(3); + response.Included.Should().HaveCount(3); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Children.ElementAt(0).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Children.ElementAt(1).StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Values[0].StringId); @@ -119,9 +119,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NameValuePairCollectionResponseDocument response = await apiClient.GetNodeValuesAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(include => include.Id == node.StringId); response.Included.OfType().Should().ContainSingle(include => include.Id == node.Parent.StringId); } @@ -156,7 +156,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ShouldNotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); - response.Included.ShouldHaveCount(1); + response.Included.Should().HaveCount(1); response.Included.OfType().Should().ContainSingle(nodeData => nodeData.Id == node.Parent.Parent.StringId).Subject.With(nodeData => { diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs index eb7ccb5bb5..1c321e4c8d 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs @@ -50,7 +50,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -83,7 +83,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); @@ -117,7 +117,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -142,7 +142,7 @@ public async Task Cannot_use_empty_page_size() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be("HTTP 400: The query string is invalid."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("400"); @@ -171,7 +171,7 @@ public async Task Cannot_use_empty_page_number() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be("HTTP 400: The query string is invalid."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("400"); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs index 0c8d1d5e55..201517cdfc 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(1).Id.Should().Be(nodes[0].StringId); } @@ -84,7 +84,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(0).StringId); } @@ -117,7 +117,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); } @@ -141,7 +141,7 @@ public async Task Cannot_use_empty_sort() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be("HTTP 400: The query string is invalid."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("400"); diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 4d3798b06d..c2f1951f72 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -48,7 +48,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => @@ -119,7 +119,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert - response.Data.ShouldHaveCount(1); + response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs index fae8c9b8dd..13a333759d 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -98,10 +98,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); response.Data.Relationships.AudioStreams.ShouldNotBeNull(); - response.Data.Relationships.AudioStreams.Data.ShouldHaveCount(1); + response.Data.Relationships.AudioStreams.Data.Should().HaveCount(1); response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); - response.Included.ShouldHaveCount(2); + response.Included.Should().HaveCount(2); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId).Subject.With( streamData => @@ -139,7 +139,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.VideoStream.ShouldNotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); - channelInDatabase.AudioStreams.ShouldHaveCount(1); + channelInDatabase.AudioStreams.Should().HaveCount(1); channelInDatabase.AudioStreams.ElementAt(0).Id.Should().Be(existingAudioStream.Id); }); } @@ -199,7 +199,7 @@ public async Task Cannot_create_resource_with_unknown_relationship_ID() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: A related resource does not exist."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs index 48572a399c..220f9a009b 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/DeleteResourceTests.cs @@ -69,7 +69,7 @@ public async Task Cannot_delete_unknown_resource() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The writeOnlyChannel does not exist."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs index db72203e60..10bbb884ca 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -94,7 +94,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsRelationshipAsync(channel.StringId!); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); } @@ -119,7 +119,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsRelationshipAsync(channel.StringId!); // Assert - response.Data.ShouldHaveCount(0); + response.Data.Should().HaveCount(0); } [Fact] @@ -138,7 +138,7 @@ public async Task Cannot_get_relationship_for_unknown_primary_ID() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs index ab044fdd05..7c149bfc3b 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -46,7 +46,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ReadOnlyChannelCollectionResponseDocument response = await apiClient.GetReadOnlyChannelCollectionAsync(); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); channel1.Attributes.ShouldNotBeNull(); @@ -126,7 +126,7 @@ public async Task Cannot_get_primary_resource_for_unknown_ID() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); @@ -204,7 +204,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsAsync(channel.StringId!); // Assert - response.Data.ShouldHaveCount(2); + response.Data.Should().HaveCount(2); DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); audioStream1.Attributes.ShouldNotBeNull(); @@ -235,7 +235,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamCollectionResponseDocument response = await apiClient.GetReadOnlyChannelAudioStreamsAsync(channel.StringId!); // Assert - response.Data.ShouldHaveCount(0); + response.Data.Should().HaveCount(0); } [Fact] @@ -254,7 +254,7 @@ public async Task Cannot_get_secondary_resource_for_unknown_primary_ID() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The readOnlyChannel does not exist."); - exception.Result.Errors.ShouldHaveCount(1); + exception.Result.Errors.Should().HaveCount(1); ErrorObject error = exception.Result.Errors.ElementAt(0); error.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs index 9ef0fd4f03..91daf96233 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -383,7 +383,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The writeOnlyChannel or a related resource does not exist."); - exception.Result.Errors.ShouldHaveCount(2); + exception.Result.Errors.Should().HaveCount(2); ErrorObject error1 = exception.Result.Errors.ElementAt(0); error1.Status.Should().Be("404"); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs index 2bb61cfccf..8e8b0a5eb6 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -108,7 +108,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Relationships.AudioStreams.ShouldNotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); - response.Included.ShouldHaveCount(1); + response.Included.Should().HaveCount(1); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -291,7 +291,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); exception.Message.Should().Be("HTTP 404: The writeOnlyChannel or a related resource does not exist."); - exception.Result.Errors.ShouldHaveCount(2); + exception.Result.Errors.Should().HaveCount(2); ErrorObject error1 = exception.Result.Errors.ElementAt(0); error1.Status.Should().Be("404"); diff --git a/test/OpenApiTests/Documentation/DocumentationTests.cs b/test/OpenApiTests/Documentation/DocumentationTests.cs index 2f35416245..1a23fc11bb 100644 --- a/test/OpenApiTests/Documentation/DocumentationTests.cs +++ b/test/OpenApiTests/Documentation/DocumentationTests.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using FluentAssertions; using TestBuildingBlocks; using Xunit; @@ -68,7 +69,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(2); + parametersElement.EnumerateArray().Should().HaveCount(2); parametersElement.Should().HaveProperty("[0].in", "query"); parametersElement.Should().HaveProperty("[0].description", ResourceTextQueryString); parametersElement.Should().HaveProperty("[1].name", "If-None-Match"); @@ -78,7 +79,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(3); + responsesElement.EnumerateObject().Should().HaveCount(3); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found skyscrapers, or an empty array if none were found."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -94,7 +95,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(2); + parametersElement.EnumerateArray().Should().HaveCount(2); parametersElement.Should().HaveProperty("[0].in", "query"); parametersElement.Should().HaveProperty("[0].description", ResourceTextQueryString); parametersElement.Should().HaveProperty("[1].name", "If-None-Match"); @@ -104,7 +105,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(3); + responsesElement.EnumerateObject().Should().HaveCount(3); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -120,7 +121,7 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "query"); parametersElement.Should().HaveProperty("[0].description", ResourceTextQueryString); }); @@ -129,7 +130,7 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(6); + responsesElement.EnumerateObject().Should().HaveCount(6); responsesElement.Should().HaveProperty("201.description", "The skyscraper was successfully created, which resulted in additional changes. The newly created skyscraper is returned."); responsesElement.Should().HaveProperty("201.headers.Location.description", "The URL at which the newly created skyscraper can be retrieved."); responsesElement.Should().HaveProperty("204.description", "The skyscraper was successfully created, which did not result in additional changes."); @@ -149,7 +150,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -161,7 +162,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found skyscraper."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -178,7 +179,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -190,7 +191,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -207,7 +208,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(2); + parametersElement.EnumerateArray().Should().HaveCount(2); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to update."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -218,7 +219,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(6); + responsesElement.EnumerateObject().Should().HaveCount(6); responsesElement.Should().HaveProperty("200.description", "The skyscraper was successfully updated, which resulted in additional changes. The updated skyscraper is returned."); responsesElement.Should().HaveProperty("204.description", "The skyscraper was successfully updated, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The query string is invalid or the request body is missing or malformed."); @@ -234,14 +235,14 @@ public async Task Endpoints_are_documented() deleteElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to delete."); }); deleteElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(2); + responsesElement.EnumerateObject().Should().HaveCount(2); responsesElement.Should().HaveProperty("204.description", "The skyscraper was successfully deleted."); responsesElement.Should().HaveProperty("404.description", "The skyscraper does not exist."); }); @@ -256,7 +257,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related elevator to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -268,7 +269,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found elevator, or `null` if it was not found."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -285,7 +286,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related elevator to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -297,7 +298,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -317,7 +318,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related elevator identity to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -329,7 +330,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found elevator identity, or `null` if it was not found."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -346,7 +347,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related elevator identity to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -358,7 +359,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -375,7 +376,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose elevator relationship to assign or clear."); }); @@ -384,7 +385,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("204.description", "The elevator relationship was successfully updated, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); @@ -401,7 +402,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related spaces to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -413,7 +414,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found spaces, or an empty array if none were found."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -430,7 +431,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related spaces to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -442,7 +443,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -462,7 +463,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related space identities to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -474,7 +475,7 @@ public async Task Endpoints_are_documented() getElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "Successfully returns the found space identities, or an empty array if none were found."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("304.description", "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header."); @@ -491,7 +492,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(3); + parametersElement.EnumerateArray().Should().HaveCount(3); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose related space identities to retrieve."); parametersElement.Should().HaveProperty("[1].in", "query"); @@ -503,7 +504,7 @@ public async Task Endpoints_are_documented() headElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("200.description", "The operation completed successfully."); responsesElement.Should().HaveProperty("200.headers.ETag.description", "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes."); responsesElement.Should().HaveProperty("200.headers.Content-Length.description", "Size of the HTTP response body, in bytes."); @@ -520,7 +521,7 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to add spaces to."); }); @@ -529,7 +530,7 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces were successfully added, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); @@ -543,7 +544,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper whose spaces relationship to assign."); }); @@ -552,7 +553,7 @@ public async Task Endpoints_are_documented() patchElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces relationship was successfully updated, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); @@ -566,7 +567,7 @@ public async Task Endpoints_are_documented() deleteElement.Should().ContainPath("parameters").With(parametersElement => { - parametersElement.EnumerateArray().ShouldHaveCount(1); + parametersElement.EnumerateArray().Should().HaveCount(1); parametersElement.Should().HaveProperty("[0].in", "path"); parametersElement.Should().HaveProperty("[0].description", "The identifier of the skyscraper to remove spaces from."); }); @@ -575,7 +576,7 @@ public async Task Endpoints_are_documented() deleteElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(4); + responsesElement.EnumerateObject().Should().HaveCount(4); responsesElement.Should().HaveProperty("204.description", "The spaces were successfully removed, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); responsesElement.Should().HaveProperty("404.description", "The skyscraper or a related resource does not exist."); @@ -594,7 +595,7 @@ public async Task Endpoints_are_documented() postElement.Should().ContainPath("responses").With(responsesElement => { - responsesElement.EnumerateObject().ShouldHaveCount(7); + responsesElement.EnumerateObject().Should().HaveCount(7); responsesElement.Should().HaveProperty("200.description", "All operations were successfully applied, which resulted in additional changes."); responsesElement.Should().HaveProperty("204.description", "All operations were successfully applied, which did not result in additional changes."); responsesElement.Should().HaveProperty("400.description", "The request body is missing or malformed."); diff --git a/test/OpenApiTests/Documentation/ErrorResponseTests.cs b/test/OpenApiTests/Documentation/ErrorResponseTests.cs index 7c76fce808..0e6970f9a6 100644 --- a/test/OpenApiTests/Documentation/ErrorResponseTests.cs +++ b/test/OpenApiTests/Documentation/ErrorResponseTests.cs @@ -34,7 +34,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp skyscrapersElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(1); + errorStatusCodeProperties.Should().HaveCount(1); errorStatusCodeProperties[0].Name.Should().Be("400"); @@ -45,7 +45,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp skyscrapersElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(1); + errorStatusCodeProperties.Should().HaveCount(1); errorStatusCodeProperties[0].Name.Should().Be("400"); @@ -55,7 +55,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp skyscrapersElement.Should().ContainPath("post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(4); + errorStatusCodeProperties.Should().HaveCount(4); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -72,7 +72,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp idElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -84,7 +84,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp idElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -95,7 +95,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp idElement.Should().ContainPath("patch.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(4); + errorStatusCodeProperties.Should().HaveCount(4); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -109,7 +109,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp idElement.Should().ContainPath("delete.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(1); + errorStatusCodeProperties.Should().HaveCount(1); errorStatusCodeProperties[0].Name.Should().Be("404"); @@ -123,7 +123,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp elevatorElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -135,7 +135,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp elevatorElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -149,7 +149,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp elevatorElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -161,7 +161,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp elevatorElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -172,7 +172,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp elevatorElement.Should().ContainPath("patch.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(3); + errorStatusCodeProperties.Should().HaveCount(3); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -188,7 +188,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -200,7 +200,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -214,7 +214,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("get.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -226,7 +226,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("head.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(2); + errorStatusCodeProperties.Should().HaveCount(2); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -237,7 +237,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(3); + errorStatusCodeProperties.Should().HaveCount(3); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -250,7 +250,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("patch.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(3); + errorStatusCodeProperties.Should().HaveCount(3); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -263,7 +263,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp spacesElement.Should().ContainPath("delete.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(3); + errorStatusCodeProperties.Should().HaveCount(3); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("404"); @@ -279,7 +279,7 @@ public async Task Applicable_error_status_codes_with_schema_are_provided_on_endp skyscrapersElement.Should().ContainPath("post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(5); + errorStatusCodeProperties.Should().HaveCount(5); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("403"); @@ -304,7 +304,7 @@ public async Task Forbidden_status_is_added_when_client_generated_IDs_are_disabl document.Should().ContainPath("paths./elevators.post.responses").With(responsesElement => { JsonProperty[] errorStatusCodeProperties = responsesElement.EnumerateObject().Where(IsErrorStatusCode).ToArray(); - errorStatusCodeProperties.ShouldHaveCount(5); + errorStatusCodeProperties.Should().HaveCount(5); errorStatusCodeProperties[0].Name.Should().Be("400"); errorStatusCodeProperties[1].Name.Should().Be("403"); diff --git a/test/OpenApiTests/Links/Disabled/LinksDisabledTests.cs b/test/OpenApiTests/Links/Disabled/LinksDisabledTests.cs index e992e3fd28..9b9cb1816a 100644 --- a/test/OpenApiTests/Links/Disabled/LinksDisabledTests.cs +++ b/test/OpenApiTests/Links/Disabled/LinksDisabledTests.cs @@ -62,7 +62,7 @@ public async Task Error_links_schema_is_visible() { string[] linkPropertyNames = propertiesElement.EnumerateObject().Select(propertyElement => propertyElement.Name).ToArray(); - linkPropertyNames.ShouldHaveCount(2); + linkPropertyNames.Should().HaveCount(2); linkPropertyNames[0].Should().Be("about"); linkPropertyNames[1].Should().Be("type"); }); From 7120fca6c0083ce7eb1f91ffb7bf905d565ec0b7 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 12:42:26 +0100 Subject: [PATCH 5/9] Remove usages of ShouldNotBeNullOrEmpty --- .../ClientIdGenerationModes/ClientIdGenerationModesTests.cs | 2 +- .../ClientIdGenerationModes/ClientIdGenerationModesTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index ce17a1d366..17e54d2820 100644 --- a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -254,7 +254,7 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden( // Assert document.ShouldNotBeNull(); document.Data.ShouldNotBeNull(); - document.Data.Id.ShouldNotBeNullOrEmpty(); + document.Data.Id.Should().NotBeNullOrEmpty(); long newPlayerGroupId = long.Parse(document.Data.Id); diff --git a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 937f7de153..936ee0e094 100644 --- a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -244,7 +244,7 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden( // Assert document.ShouldNotBeNull(); - document.Data.Id.ShouldNotBeNullOrEmpty(); + document.Data.Id.Should().NotBeNullOrEmpty(); long newPlayerGroupId = long.Parse(document.Data.Id); From 82c48a2cab19e8e6e392f17d7e98cc88846f1108 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 12:45:57 +0100 Subject: [PATCH 6/9] Remove usages of ShouldContainKey --- test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs | 6 +++--- .../QueryStrings/PaginationTests.cs | 6 +++--- test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs | 6 +++--- .../QueryStrings/PaginationTests.cs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs index 6459508407..a52c78ad87 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs @@ -65,7 +65,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.AdditionalData.Should().ContainKey("total").With(total => total.Should().Be(1)); } } @@ -110,7 +110,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.AdditionalData.Should().ContainKey("total").With(total => total.Should().Be(1)); } } @@ -148,7 +148,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(1); response.Links.ShouldNotBeNull(); response.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); } diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs index 8b835840ea..245aa93c71 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs @@ -57,7 +57,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } @@ -95,7 +95,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } @@ -132,7 +132,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs index 87a0432828..2557c39360 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs @@ -61,7 +61,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); } [Fact] @@ -102,7 +102,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); } [Fact] @@ -136,7 +136,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(1)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); response.Links.ShouldNotBeNull(); response.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs index 1c321e4c8d..d04d400095 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs @@ -53,7 +53,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } [Fact] @@ -87,7 +87,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } [Fact] @@ -120,7 +120,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); response.Meta.ShouldNotBeNull(); - response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); + response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } [Fact] From b20fc706f5aada7b1521f36228178feffbab85d4 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 12:47:37 +0100 Subject: [PATCH 7/9] Remove usages of ShouldNotBeNull and redundant With calls --- .../AtomicCreateResourceTests.cs | 8 +-- .../AtomicOperations/AtomicLocalIdTests.cs | 10 ++-- .../AtomicRelationshipTests.cs | 2 +- .../AtomicUpdateResourceTests.cs | 16 +++--- .../ClientIdGenerationModesTests.cs | 12 ++--- .../Headers/ETagTests.cs | 6 +-- .../Headers/HeaderTests.cs | 4 +- .../Links/AlternateOpenApiRouteTests.cs | 4 +- .../ModelStateValidationTests.cs | 28 +++++----- .../QueryStrings/FilterTests.cs | 26 +++++----- .../QueryStrings/IncludeTests.cs | 18 +++---- .../QueryStrings/PaginationTests.cs | 16 +++--- .../QueryStrings/SortTests.cs | 8 +-- .../QueryStrings/SparseFieldSetTests.cs | 36 ++++++------- .../CreateResourceTests.cs | 22 ++++---- .../FetchRelationshipTests.cs | 10 ++-- .../FetchResourceTests.cs | 52 +++++++++---------- .../UpdateRelationshipTests.cs | 2 +- .../UpdateResourceTests.cs | 34 ++++++------ .../LegacyOpenApi/RequestTests.cs | 28 +++++----- .../LegacyOpenApi/ResponseTests.cs | 9 ++-- .../NullabilityTests.cs | 7 ++- .../NullabilityTests.cs | 7 ++- .../NullabilityTests.cs | 7 ++- .../NullabilityTests.cs | 7 ++- .../AtomicCreateResourceTests.cs | 8 +-- .../AtomicOperations/AtomicLocalIdTests.cs | 10 ++-- .../AtomicRelationshipTests.cs | 2 +- .../AtomicUpdateResourceTests.cs | 16 +++--- .../ClientIdGenerationModesTests.cs | 6 +-- .../Headers/ETagTests.cs | 6 +-- .../Headers/HeaderTests.cs | 2 +- .../ModelStateValidationTests.cs | 26 +++++----- .../QueryStrings/FilterTests.cs | 16 +++--- .../QueryStrings/IncludeTests.cs | 4 +- .../QueryStrings/PaginationTests.cs | 10 ++-- .../QueryStrings/SortTests.cs | 2 +- .../QueryStrings/SparseFieldSetTests.cs | 22 ++++---- .../CreateResourceTests.cs | 20 +++---- .../FetchRelationshipTests.cs | 2 +- .../FetchResourceTests.cs | 40 +++++++------- .../UpdateRelationshipTests.cs | 2 +- .../UpdateResourceTests.cs | 30 +++++------ 43 files changed, 299 insertions(+), 304 deletions(-) diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs index baf0939624..9e9027536e 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs @@ -61,12 +61,12 @@ public async Task Can_create_resource_with_attributes() OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(1); TeacherDataInResponse teacherDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; - teacherDataInResponse.Attributes.ShouldNotBeNull(); + teacherDataInResponse.Attributes.Should().NotBeNull(); teacherDataInResponse.Attributes.Name.Should().Be(newTeacher.Name); teacherDataInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress); @@ -140,12 +140,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; - enrollmentDataInResponse.Attributes.ShouldNotBeNull(); + enrollmentDataInResponse.Attributes.Should().NotBeNull(); enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrollment.EnrolledAt); enrollmentDataInResponse.Attributes.GraduatedAt.Should().BeNull(); enrollmentDataInResponse.Attributes.HasGraduated.Should().BeFalse(); diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs index 61828a60a3..e08d2283bb 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs @@ -172,12 +172,12 @@ public async Task Can_use_local_IDs() OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(7); TeacherDataInResponse teacherInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; - teacherInResponse.Attributes.ShouldNotBeNull(); + teacherInResponse.Attributes.Should().NotBeNull(); teacherInResponse.Attributes.Name.Should().Be(newTeacher.Name); teacherInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress); long newTeacherId = long.Parse(teacherInResponse.Id!); @@ -186,13 +186,13 @@ public async Task Can_use_local_IDs() response.AtomicResults.ElementAt(2).Data.Should().BeNull(); StudentDataInResponse studentInResponse = response.AtomicResults.ElementAt(3).Data.Should().BeOfType().Which; - studentInResponse.Attributes.ShouldNotBeNull(); + studentInResponse.Attributes.Should().NotBeNull(); studentInResponse.Attributes.Name.Should().Be(newStudent.Name); studentInResponse.Attributes.EmailAddress.Should().Be(newStudent.EmailAddress); long newStudentId = long.Parse(studentInResponse.Id!); EnrollmentDataInResponse enrollmentInResponse = response.AtomicResults.ElementAt(4).Data.Should().BeOfType().Which; - enrollmentInResponse.Attributes.ShouldNotBeNull(); + enrollmentInResponse.Attributes.Should().NotBeNull(); enrollmentInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrolledAt); long newEnrollmentId = long.Parse(enrollmentInResponse.Id!); @@ -226,7 +226,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_chained_method_calls restore enrollmentInDatabase.EnrolledAt.Should().Be(newEnrolledAt); - enrollmentInDatabase.Course.ShouldNotBeNull(); + enrollmentInDatabase.Course.Should().NotBeNull(); enrollmentInDatabase.Course.Id.Should().Be(newCourse.Id); enrollmentInDatabase.Student.Id.Should().Be(newStudentId); }); diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs index 2915a80f92..cb97361eb7 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs @@ -79,7 +79,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Enrollment enrollmentInDatabase = await dbContext.Enrollments.Include(enrollment => enrollment.Student).FirstWithIdAsync(existingEnrollment.Id); - enrollmentInDatabase.Student.ShouldNotBeNull(); + enrollmentInDatabase.Student.Should().NotBeNull(); enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id); }); } diff --git a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs index 47b682b943..804e9bd627 100644 --- a/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs @@ -75,13 +75,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); - studentDataInResponse.Attributes.ShouldNotBeNull(); + studentDataInResponse.Attributes.Should().NotBeNull(); studentDataInResponse.Attributes.Name.Should().Be(newName); studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress); @@ -139,13 +139,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); - studentDataInResponse.Attributes.ShouldNotBeNull(); + studentDataInResponse.Attributes.Should().NotBeNull(); studentDataInResponse.Attributes.Name.Should().Be(existingStudent.Name); studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress); @@ -222,13 +222,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.AtomicResults.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Id.Should().Be(existingEnrollment.StringId); - enrollmentDataInResponse.Attributes.ShouldNotBeNull(); + enrollmentDataInResponse.Attributes.Should().NotBeNull(); enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be((Date)newEnrolledAt); enrollmentDataInResponse.Attributes.GraduatedAt.Should().Be((Date)existingEnrollment.GraduatedAt!.Value); enrollmentDataInResponse.Attributes.HasGraduated.Should().Be(existingEnrollment.HasGraduated); @@ -250,10 +250,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => enrollmentInDatabase.GraduatedAt.Should().Be(existingEnrollment.GraduatedAt); enrollmentInDatabase.HasGraduated.Should().Be(existingEnrollment.HasGraduated); - enrollmentInDatabase.Student.ShouldNotBeNull(); + enrollmentInDatabase.Student.Should().NotBeNull(); enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id); - enrollmentInDatabase.Course.ShouldNotBeNull(); + enrollmentInDatabase.Course.Should().NotBeNull(); enrollmentInDatabase.Course.Id.Should().Be(existingCourse.Id); }); } diff --git a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 17e54d2820..a062742721 100644 --- a/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -63,7 +63,7 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require error.Status.Should().Be("422"); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is required."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); } @@ -130,9 +130,9 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_allowed() GamePrimaryResponseDocument? document = await apiClient.Games.PostAsync(requestBody); // Assert - document.ShouldNotBeNull(); - document.Data.ShouldNotBeNull(); - document.Data.Id.ShouldNotBeNull(); + document.Should().NotBeNull(); + document.Data.Should().NotBeNull(); + document.Data.Id.Should().NotBeNull(); document.Data.Id.Value.Should().NotBe(Guid.Empty); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -252,8 +252,8 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden( PlayerGroupPrimaryResponseDocument? document = await apiClient.PlayerGroups.PostAsync(requestBody); // Assert - document.ShouldNotBeNull(); - document.Data.ShouldNotBeNull(); + document.Should().NotBeNull(); + document.Data.Should().NotBeNull(); document.Data.Id.Should().NotBeNullOrEmpty(); long newPlayerGroupId = long.Parse(document.Data.Id); diff --git a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs index 1b7102523c..cab06d306d 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs @@ -83,7 +83,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => CountryCollectionResponseDocument? response = await apiClient.Countries.GetAsync(configuration => configuration.Options.Add(headerInspector)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); eTagHeaderValues.Should().HaveCount(1); @@ -153,7 +153,7 @@ public async Task Returns_no_ETag_for_POST_request() await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); headerInspector.ResponseHeaders.Should().NotContainKey(HeaderNames.ETag); } @@ -230,7 +230,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); string[] eTagHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.ToArray(); eTagHeaderValues.Should().HaveCount(1); diff --git a/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs index 7e56f5ecb5..4a18a0ebeb 100644 --- a/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Headers/HeaderTests.cs @@ -58,8 +58,8 @@ public async Task Returns_Location_for_post_resource_request() await apiClient.Countries.PostAsync(requestBody, configuration => configuration.Options.Add(headerInspector)); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); string[] locationHeaderValues = headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); locationHeaderValues.Should().HaveCount(1); diff --git a/test/OpenApiKiotaEndToEndTests/Links/AlternateOpenApiRouteTests.cs b/test/OpenApiKiotaEndToEndTests/Links/AlternateOpenApiRouteTests.cs index 411471c687..fff4de85ae 100644 --- a/test/OpenApiKiotaEndToEndTests/Links/AlternateOpenApiRouteTests.cs +++ b/test/OpenApiKiotaEndToEndTests/Links/AlternateOpenApiRouteTests.cs @@ -48,8 +48,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ExcursionPrimaryResponseDocument? response = await apiClient.Excursions[excursion.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Links.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Links.Should().NotBeNull(); response.Links.Describedby.Should().Be("/api-docs/v1/swagger.yaml"); } diff --git a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index 667a4e2f8e..96e4edd89d 100644 --- a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -65,7 +65,7 @@ public async Task Cannot_exceed_length_constraint(string firstName) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/firstName"); } @@ -103,7 +103,7 @@ public async Task Cannot_exceed_string_length_constraint(string userName) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); } @@ -139,7 +139,7 @@ public async Task Cannot_violate_regular_expression_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("Only letters are allowed."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); } @@ -175,7 +175,7 @@ public async Task Cannot_use_invalid_credit_card_number() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The CreditCard field is not a valid credit card number."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/creditCard"); } @@ -211,7 +211,7 @@ public async Task Cannot_use_invalid_email_address() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The Email field is not a valid e-mail address."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/email"); } @@ -250,7 +250,7 @@ public async Task Cannot_exceed_min_length_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/password"); } @@ -288,7 +288,7 @@ public async Task Cannot_exceed_max_length_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/password"); } @@ -324,7 +324,7 @@ public async Task Cannot_use_invalid_base64() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The Password field is not a valid Base64 encoding."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/password"); } @@ -364,7 +364,7 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/age"); } @@ -400,7 +400,7 @@ public async Task Cannot_use_relative_url() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); } @@ -438,7 +438,7 @@ public async Task Cannot_exceed_collection_length_constraint(int length) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/tags"); } @@ -474,7 +474,7 @@ public async Task Cannot_use_non_allowed_value() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/countryCode"); } @@ -510,7 +510,7 @@ public async Task Cannot_use_denied_value() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/planet"); } @@ -546,7 +546,7 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); } diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs index a52c78ad87..76095c4c69 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs @@ -54,18 +54,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(nodes[1].Name); attributes.Comment.Should().Be(nodes[1].Comment); }); - response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.Should().ContainKey("total").With(total => total.Should().Be(1)); + response.Meta.Should().NotBeNull(); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(1); } } @@ -99,18 +99,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(node.Children.ElementAt(1).Name); attributes.Comment.Should().Be(node.Children.ElementAt(1).Comment); }); - response.Meta.ShouldNotBeNull(); - response.Meta.AdditionalData.Should().ContainKey("total").With(total => total.Should().Be(1)); + response.Meta.Should().NotBeNull(); + response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(1); } } @@ -144,12 +144,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Relationships.Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(1); - response.Links.ShouldNotBeNull(); + response.Links.Should().NotBeNull(); response.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); } } @@ -175,7 +175,7 @@ public async Task Cannot_use_empty_filter() ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); - exception.Links.ShouldNotBeNull(); + exception.Links.Should().NotBeNull(); exception.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); exception.Errors.Should().HaveCount(1); @@ -183,7 +183,7 @@ public async Task Cannot_use_empty_filter() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'filter' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } } diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs index 0984487614..92deaaa94b 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs @@ -53,7 +53,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); @@ -92,8 +92,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.StringId); response.Included.Should().HaveCount(3); @@ -132,7 +132,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NameValuePairCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Values.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Included.Should().HaveCount(2); @@ -170,8 +170,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NullableNodeSecondaryResponseDocument? response = await apiClient.Nodes[node.StringId!].Parent.GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); response.Included.Should().HaveCount(1); @@ -179,7 +179,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Included.OfType().Should().ContainSingle(nodeData => nodeData.Id == node.Parent.Parent.StringId).Subject.With( nodeData => { - nodeData.Attributes.ShouldNotBeNull(); + nodeData.Attributes.Should().NotBeNull(); nodeData.Attributes.Name.Should().Be(node.Parent.Parent.Name); }); } @@ -211,8 +211,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.StringId); response.Included.Should().BeEmpty(); diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs index 245aa93c71..247a45f4f0 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs @@ -53,10 +53,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } @@ -90,11 +90,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } @@ -128,10 +128,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Relationships.Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.AdditionalData.Should().ContainKey("total").WhoseValue.Should().Be(3); } } @@ -163,7 +163,7 @@ public async Task Cannot_use_empty_page_size() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'page[size]' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } } @@ -195,7 +195,7 @@ public async Task Cannot_use_empty_page_number() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'page[number]' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } } diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs index 7fa03f8b09..15c6c2765c 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs @@ -54,7 +54,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(1).Id.Should().Be(nodes[0].StringId); @@ -91,7 +91,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(0).StringId); @@ -128,7 +128,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Relationships.Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); @@ -162,7 +162,7 @@ public async Task Cannot_use_empty_sort() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'sort' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } } diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 2a61043a40..6aae375905 100644 --- a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -52,11 +52,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(node.Name); attributes.Comment.Should().BeNull(); @@ -92,14 +92,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Comment); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.Parent.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Parent.Should().NotBeNull(); response.Data.Relationships.Children.Should().BeNull(); } } @@ -132,20 +132,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId!].Children.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().BeNull(); attributes.Comment.Should().Be(node.Children.ElementAt(0).Comment); }); - response.Data.ElementAt(0).Relationships.ShouldNotBeNull().With(relationships => + response.Data.ElementAt(0).Relationships.RefShould().NotBeNull().And.Subject.With(relationships => { relationships.Parent.Should().BeNull(); - relationships.Children.ShouldNotBeNull(); + relationships.Children.Should().NotBeNull(); }); } } @@ -177,15 +177,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NullableNodeSecondaryResponseDocument? response = await apiClient.Nodes[node.StringId!].Parent.GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Parent.Comment); - response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); response.Data.Relationships.Parent.Should().BeNull(); - response.Data.Relationships.Children.ShouldNotBeNull(); + response.Data.Relationships.Children.Should().NotBeNull(); } } @@ -215,8 +215,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.StringId); response.Data.Attributes.Should().BeNull(); } diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs index 248c347966..f5633a0e55 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -91,19 +91,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Act WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels.PostAsync(requestBody); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); - response.Data.ShouldNotBeNull(); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(newChannel.Name); response.Data.Attributes.IsCommercial.Should().BeNull(); response.Data.Attributes.IsAdultOnly.Should().BeNull(); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().HaveCount(1); response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); @@ -112,18 +112,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId).Subject .With(streamData => { - streamData.Attributes.ShouldNotBeNull(); + streamData.Attributes.Should().NotBeNull(); streamData.Attributes.BytesTransmitted.Should().Be((long?)existingVideoStream.BytesTransmitted); }); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingAudioStream.StringId).Subject .With(streamData => { - streamData.Attributes.ShouldNotBeNull(); + streamData.Attributes.Should().NotBeNull(); streamData.Attributes.BytesTransmitted.Should().Be((long?)existingAudioStream.BytesTransmitted); }); - long newChannelId = long.Parse(response.Data.Id.ShouldNotBeNull()); + long newChannelId = long.Parse(response.Data.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().BeNull(); channelInDatabase.IsAdultOnly.Should().Be(newChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); channelInDatabase.AudioStreams.Should().HaveCount(1); diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs index ed51c31362..9baa1d0f3e 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -46,8 +46,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].Relationships.VideoStream.GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.VideoStream.StringId); } @@ -72,7 +72,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await apiClient.ReadOnlyChannels[channel.StringId!].Relationships.UltraHighDefinitionVideoStream.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().BeNull(); } @@ -97,7 +97,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].Relationships.AudioStreams.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); response.Data.Should().ContainSingle(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); @@ -123,7 +123,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].Relationships.AudioStreams.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(0); } diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs index 2cc4c848d8..5fff410d9c 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -47,33 +47,33 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ReadOnlyChannelCollectionResponseDocument? response = await apiClient.ReadOnlyChannels.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); - channel1.Attributes.ShouldNotBeNull(); + channel1.Attributes.Should().NotBeNull(); channel1.Attributes.Name.Should().Be(channels[0].Name); channel1.Attributes.IsCommercial.Should().Be(channels[0].IsCommercial); channel1.Attributes.IsAdultOnly.Should().Be(channels[0].IsAdultOnly); - channel1.Relationships.ShouldNotBeNull(); - channel1.Relationships.VideoStream.ShouldNotBeNull(); + channel1.Relationships.Should().NotBeNull(); + channel1.Relationships.VideoStream.Should().NotBeNull(); channel1.Relationships.VideoStream.Data.Should().BeNull(); - channel1.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel1.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); channel1.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - channel1.Relationships.AudioStreams.ShouldNotBeNull(); + channel1.Relationships.AudioStreams.Should().NotBeNull(); channel1.Relationships.AudioStreams.Data.Should().BeNull(); ReadOnlyChannelDataInResponse channel2 = response.Data.Single(channel => channel.Id == channels.ElementAt(1).StringId); - channel2.Attributes.ShouldNotBeNull(); + channel2.Attributes.Should().NotBeNull(); channel2.Attributes.Name.Should().Be(channels[1].Name); channel2.Attributes.IsCommercial.Should().Be(channels[1].IsCommercial); channel2.Attributes.IsAdultOnly.Should().Be(channels[1].IsAdultOnly); - channel2.Relationships.ShouldNotBeNull(); - channel2.Relationships.VideoStream.ShouldNotBeNull(); + channel2.Relationships.Should().NotBeNull(); + channel2.Relationships.VideoStream.Should().NotBeNull(); channel2.Relationships.VideoStream.Data.Should().BeNull(); - channel2.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel2.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); channel2.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - channel2.Relationships.AudioStreams.ShouldNotBeNull(); + channel2.Relationships.AudioStreams.Should().NotBeNull(); channel2.Relationships.AudioStreams.Data.Should().BeNull(); } @@ -97,19 +97,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ReadOnlyChannelPrimaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(channel.Name); response.Data.Attributes.IsCommercial.Should().Be(channel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().Be(channel.IsAdultOnly); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Should().BeNull(); - response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeNull(); } @@ -157,10 +157,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamSecondaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].VideoStream.GetAsync(); // Assert - response.ShouldNotBeNull(); - response.Data.ShouldNotBeNull(); + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.VideoStream.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.BytesTransmitted.Should().Be((long?)channel.VideoStream.BytesTransmitted); } @@ -184,7 +184,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NullableDataStreamSecondaryResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].UltraHighDefinitionVideoStream.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().BeNull(); } @@ -209,15 +209,15 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].AudioStreams.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(2); DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); - audioStream1.Attributes.ShouldNotBeNull(); + audioStream1.Attributes.Should().NotBeNull(); audioStream1.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(0).BytesTransmitted); DataStreamDataInResponse audioStream2 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); - audioStream2.Attributes.ShouldNotBeNull(); + audioStream2.Attributes.Should().NotBeNull(); audioStream2.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(1).BytesTransmitted); } @@ -241,7 +241,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamCollectionResponseDocument? response = await apiClient.ReadOnlyChannels[channel.StringId!].AudioStreams.GetAsync(); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Should().HaveCount(0); } diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs index c8b5425c5e..87fcbbfbdb 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -71,7 +71,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:keep_existing_linebreaks restore // @formatter:wrap_chained_method_calls restore - channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Should().NotBeNull(); channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingVideoStream.Id); }); } diff --git a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs index db365db1f1..9d8be2cb00 100644 --- a/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs +++ b/test/OpenApiKiotaEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -97,20 +97,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Act WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels[existingChannel.StringId!].PatchAsync(requestBody); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(existingChannel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(newChannelName); response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().BeNull(); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); response.Included.Should().HaveCount(1); @@ -134,7 +134,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); @@ -176,20 +176,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Act WriteOnlyChannelPrimaryResponseDocument? response = await apiClient.WriteOnlyChannels[existingChannel.StringId!].PatchAsync(requestBody); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(existingChannel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(existingChannel.Name); response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Should().BeNull(); - response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -210,10 +210,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingChannel.VideoStream.Id); - channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Should().NotBeNull(); channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingChannel.UltraHighDefinitionVideoStream.Id); channelInDatabase.AudioStreams.Should().HaveCount(2); diff --git a/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs index b8622ed185..d9fb16551f 100644 --- a/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/RequestTests.cs @@ -26,7 +26,7 @@ public async Task Getting_resource_collection_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCollectionAsync(null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights"); @@ -46,7 +46,7 @@ public async Task Getting_resource_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightAsync(flightId, null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}"); @@ -88,7 +88,7 @@ public async Task Partial_posting_resource_with_selected_relationships_produces_ _ = await ApiResponse.TranslateAsync(async () => await apiClient.PostFlightAsync(null, requestDocument)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Post); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights"); @@ -159,7 +159,7 @@ public async Task Partial_posting_resource_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.PostAirplaneAsync(null, requestDocument)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Post); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}airplanes"); @@ -213,7 +213,7 @@ public async Task Partial_patching_resource_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.PatchAirplaneAsync(airplaneId, null, requestDocument)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Patch); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}airplanes/{airplaneId}"); @@ -250,7 +250,7 @@ public async Task Deleting_resource_produces_expected_request() await apiClient.DeleteFlightAsync(flightId); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Method.Should().Be(HttpMethod.Delete); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}"); wrapper.RequestBody.Should().BeNull(); @@ -269,7 +269,7 @@ public async Task Getting_secondary_resource_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightPurserAsync(flightId, null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/purser"); @@ -289,7 +289,7 @@ public async Task Getting_secondary_resources_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCabinCrewMembersAsync(flightId, null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/cabin-crew-members"); @@ -309,7 +309,7 @@ public async Task Getting_ToOne_relationship_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightPurserRelationshipAsync(flightId, null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/purser"); @@ -337,7 +337,7 @@ public async Task Patching_ToOne_relationship_produces_expected_request() await apiClient.PatchFlightPurserRelationshipAsync(flightId, requestDocument); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Method.Should().Be(HttpMethod.Patch); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/purser"); wrapper.Request.Content.Should().NotBeNull(); @@ -367,7 +367,7 @@ public async Task Getting_ToMany_relationship_produces_expected_request() _ = await ApiResponse.TranslateAsync(async () => await apiClient.GetFlightCabinCrewMembersRelationshipAsync(flightId, null, null)); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Headers.GetValue(HeaderNames.Accept).Should().Be(JsonApiMediaType.Default.ToString()); wrapper.Request.Method.Should().Be(HttpMethod.Get); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/cabin-crew-members"); @@ -402,7 +402,7 @@ public async Task Posting_ToMany_relationship_produces_expected_request() await apiClient.PostFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Method.Should().Be(HttpMethod.Post); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/cabin-crew-members"); wrapper.Request.Content.Should().NotBeNull(); @@ -453,7 +453,7 @@ public async Task Patching_ToMany_relationship_produces_expected_request() await apiClient.PatchFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Method.Should().Be(HttpMethod.Patch); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/cabin-crew-members"); wrapper.Request.Content.Should().NotBeNull(); @@ -504,7 +504,7 @@ public async Task Deleting_ToMany_relationship_produces_expected_request() await apiClient.DeleteFlightCabinCrewMembersRelationshipAsync(flightId, requestDocument); // Assert - wrapper.Request.ShouldNotBeNull(); + wrapper.Request.Should().NotBeNull(); wrapper.Request.Method.Should().Be(HttpMethod.Delete); wrapper.Request.RequestUri.Should().Be($"{HostPrefix}flights/{flightId}/relationships/cabin-crew-members"); wrapper.Request.Content.Should().NotBeNull(); diff --git a/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs index ceec38dd03..212a48e34e 100644 --- a/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyOpenApi/ResponseTests.cs @@ -3,7 +3,6 @@ using FluentAssertions; using JsonApiDotNetCore.OpenApi.Client.NSwag; using OpenApiNSwagClientTests.LegacyOpenApi.GeneratedCode; -using TestBuildingBlocks; using Xunit; namespace OpenApiNSwagClientTests.LegacyOpenApi; @@ -226,7 +225,7 @@ public async Task Getting_unknown_resource_translates_error_response() // Assert ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); - exception.Result.Links.ShouldNotBeNull(); + exception.Result.Links.Should().NotBeNull(); exception.Result.Links.Self.Should().Be("http://localhost/api/flights/ZvuH1"); exception.Result.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); exception.Result.Errors.Should().HaveCount(1); @@ -317,7 +316,7 @@ public async Task Posting_resource_translates_response() // Assert document.Data.Attributes.Should().BeNull(); - document.Data.Relationships.Purser.Data.ShouldNotBeNull(); + document.Data.Relationships.Purser.Data.Should().NotBeNull(); document.Data.Relationships.Purser.Data.Id.Should().Be(flightAttendantId); document.Data.Relationships.CabinCrewMembers.Data.Should().HaveCount(1); document.Data.Relationships.CabinCrewMembers.Data.First().Id.Should().Be(flightAttendantId); @@ -456,7 +455,7 @@ public async Task Getting_secondary_resource_translates_response() FlightAttendantSecondaryResponseDocument document = await apiClient.GetFlightPurserAsync(flightId, null, null); // Assert - document.Data.ShouldNotBeNull(); + document.Data.Should().NotBeNull(); document.Data.Id.Should().Be(purserId); document.Data.Attributes.EmailAddress.Should().Be(emailAddress); document.Data.Attributes.Age.Should().Be(int.Parse(age)); @@ -570,7 +569,7 @@ public async Task Getting_ToOne_relationship_translates_response() FlightAttendantIdentifierResponseDocument document = await apiClient.GetFlightPurserRelationshipAsync(flightId, null, null); // Assert - document.Data.ShouldNotBeNull(); + document.Data.Should().NotBeNull(); document.Data.Id.Should().Be(purserId); document.Data.Type.Should().Be(FlightAttendantResourceType.FlightAttendants); } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs index 2b1d88fe67..ff3b027b89 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs @@ -1,7 +1,6 @@ using System.Reflection; using FluentAssertions; using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; -using TestBuildingBlocks; using Xunit; namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; @@ -21,7 +20,7 @@ public void Nullability_of_generated_attribute_property_is_as_expected(string pr PropertyInfo? property = typeof(AttributesInCreateResourceRequest).GetProperty(propertyName); // Assert - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.Should().HaveNullabilityState(expectedState); } @@ -36,10 +35,10 @@ public void Nullability_of_generated_relationship_property_is_as_expected(string PropertyInfo? relationshipProperty = typeof(RelationshipsInCreateResourceRequest).GetProperty(propertyName); // Assert - relationshipProperty.ShouldNotBeNull(); + relationshipProperty.Should().NotBeNull(); PropertyInfo? dataProperty = relationshipProperty.PropertyType.GetProperty("Data"); - dataProperty.ShouldNotBeNull(); + dataProperty.Should().NotBeNull(); dataProperty.Should().HaveNullabilityState(expectedState); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs index 989c7a60fe..e6274f85b1 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs @@ -1,7 +1,6 @@ using System.Reflection; using FluentAssertions; using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; -using TestBuildingBlocks; using Xunit; namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; @@ -21,7 +20,7 @@ public void Nullability_of_generated_attribute_property_is_as_expected(string pr PropertyInfo? property = typeof(AttributesInCreateResourceRequest).GetProperty(propertyName); // Assert - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.Should().HaveNullabilityState(expectedState); } @@ -36,10 +35,10 @@ public void Nullability_of_generated_relationship_property_is_as_expected(string PropertyInfo? relationshipProperty = typeof(RelationshipsInCreateResourceRequest).GetProperty(propertyName); // Assert - relationshipProperty.ShouldNotBeNull(); + relationshipProperty.Should().NotBeNull(); PropertyInfo? dataProperty = relationshipProperty.PropertyType.GetProperty("Data"); - dataProperty.ShouldNotBeNull(); + dataProperty.Should().NotBeNull(); dataProperty.Should().HaveNullabilityState(expectedState); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs index 87cb770fb2..8c7e3baa45 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs @@ -1,7 +1,6 @@ using System.Reflection; using FluentAssertions; using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; -using TestBuildingBlocks; using Xunit; namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; @@ -23,7 +22,7 @@ public void Nullability_of_generated_attribute_property_is_as_expected(string pr PropertyInfo? property = typeof(AttributesInCreateResourceRequest).GetProperty(propertyName); // Assert - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.Should().HaveNullabilityState(expectedState); } @@ -40,10 +39,10 @@ public void Nullability_of_generated_relationship_property_is_as_expected(string PropertyInfo? relationshipProperty = typeof(RelationshipsInCreateResourceRequest).GetProperty(propertyName); // Assert - relationshipProperty.ShouldNotBeNull(); + relationshipProperty.Should().NotBeNull(); PropertyInfo? dataProperty = relationshipProperty.PropertyType.GetProperty("Data"); - dataProperty.ShouldNotBeNull(); + dataProperty.Should().NotBeNull(); dataProperty.Should().HaveNullabilityState(expectedState); } } diff --git a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs index 452ecf0bc9..15da38bfe1 100644 --- a/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs @@ -1,7 +1,6 @@ using System.Reflection; using FluentAssertions; using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; -using TestBuildingBlocks; using Xunit; namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; @@ -23,7 +22,7 @@ public void Nullability_of_generated_attribute_property_is_as_expected(string pr PropertyInfo? property = typeof(AttributesInCreateResourceRequest).GetProperty(propertyName); // Assert - property.ShouldNotBeNull(); + property.Should().NotBeNull(); property.Should().HaveNullabilityState(expectedState); } @@ -40,10 +39,10 @@ public void Nullability_of_generated_relationship_property_is_as_expected(string PropertyInfo? relationshipProperty = typeof(RelationshipsInCreateResourceRequest).GetProperty(propertyName); // Assert - relationshipProperty.ShouldNotBeNull(); + relationshipProperty.Should().NotBeNull(); PropertyInfo? dataProperty = relationshipProperty.PropertyType.GetProperty("Data"); - dataProperty.ShouldNotBeNull(); + dataProperty.Should().NotBeNull(); dataProperty.Should().HaveNullabilityState(expectedState); } } diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs index 632cf06aaa..3dbcc59133 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicCreateResourceTests.cs @@ -58,12 +58,12 @@ public async Task Can_create_resource_with_attributes() OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(1); TeacherDataInResponse teacherDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; - teacherDataInResponse.Attributes.ShouldNotBeNull(); + teacherDataInResponse.Attributes.Should().NotBeNull(); teacherDataInResponse.Attributes.Name.Should().Be(newTeacher.Name); teacherDataInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress); @@ -133,12 +133,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; - enrollmentDataInResponse.Attributes.ShouldNotBeNull(); + enrollmentDataInResponse.Attributes.Should().NotBeNull(); enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be(newEnrollment.EnrolledAt.ToDateTime(TimeOnly.MinValue)); enrollmentDataInResponse.Attributes.GraduatedAt.Should().BeNull(); enrollmentDataInResponse.Attributes.HasGraduated.Should().BeFalse(); diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs index 3db0a8d6b7..0dde1ba7e5 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicLocalIdTests.cs @@ -150,12 +150,12 @@ public async Task Can_use_local_IDs() OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(7); TeacherDataInResponse teacherInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; - teacherInResponse.Attributes.ShouldNotBeNull(); + teacherInResponse.Attributes.Should().NotBeNull(); teacherInResponse.Attributes.Name.Should().Be(newTeacher.Name); teacherInResponse.Attributes.EmailAddress.Should().Be(newTeacher.EmailAddress); long newTeacherId = long.Parse(teacherInResponse.Id); @@ -164,13 +164,13 @@ public async Task Can_use_local_IDs() response.Atomic_results.ElementAt(2).Data.Should().BeNull(); StudentDataInResponse studentInResponse = response.Atomic_results.ElementAt(3).Data.Should().BeOfType().Which; - studentInResponse.Attributes.ShouldNotBeNull(); + studentInResponse.Attributes.Should().NotBeNull(); studentInResponse.Attributes.Name.Should().Be(newStudent.Name); studentInResponse.Attributes.EmailAddress.Should().Be(newStudent.EmailAddress); long newStudentId = long.Parse(studentInResponse.Id); EnrollmentDataInResponse enrollmentInResponse = response.Atomic_results.ElementAt(4).Data.Should().BeOfType().Which; - enrollmentInResponse.Attributes.ShouldNotBeNull(); + enrollmentInResponse.Attributes.Should().NotBeNull(); enrollmentInResponse.Attributes.EnrolledAt.Should().Be(newEnrolledAt.ToDateTime(TimeOnly.MinValue)); long newEnrollmentId = long.Parse(enrollmentInResponse.Id); @@ -204,7 +204,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:wrap_chained_method_calls restore enrollmentInDatabase.EnrolledAt.Should().Be(newEnrolledAt); - enrollmentInDatabase.Course.ShouldNotBeNull(); + enrollmentInDatabase.Course.Should().NotBeNull(); enrollmentInDatabase.Course.Id.Should().Be(newCourse.Id); enrollmentInDatabase.Student.Id.Should().Be(newStudentId); }); diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs index c2c491dfbe..39863bd8c7 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicRelationshipTests.cs @@ -74,7 +74,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => { Enrollment enrollmentInDatabase = await dbContext.Enrollments.Include(enrollment => enrollment.Student).FirstWithIdAsync(existingEnrollment.Id); - enrollmentInDatabase.Student.ShouldNotBeNull(); + enrollmentInDatabase.Student.Should().NotBeNull(); enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id); }); } diff --git a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs index e7d2e56c56..ee7d8a5c62 100644 --- a/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/AtomicOperations/AtomicUpdateResourceTests.cs @@ -71,13 +71,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); - studentDataInResponse.Attributes.ShouldNotBeNull(); + studentDataInResponse.Attributes.Should().NotBeNull(); studentDataInResponse.Attributes.Name.Should().Be(newName); studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress); @@ -132,13 +132,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(1); StudentDataInResponse studentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; studentDataInResponse.Id.Should().Be(existingStudent.StringId); - studentDataInResponse.Attributes.ShouldNotBeNull(); + studentDataInResponse.Attributes.Should().NotBeNull(); studentDataInResponse.Attributes.Name.Should().Be(existingStudent.Name); studentDataInResponse.Attributes.EmailAddress.Should().Be(newEmailAddress); @@ -211,13 +211,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); // Assert - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Atomic_results.Should().HaveCount(1); EnrollmentDataInResponse enrollmentDataInResponse = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Which; enrollmentDataInResponse.Id.Should().Be(existingEnrollment.StringId); - enrollmentDataInResponse.Attributes.ShouldNotBeNull(); + enrollmentDataInResponse.Attributes.Should().NotBeNull(); enrollmentDataInResponse.Attributes.EnrolledAt.Should().Be(newEnrolledAt.ToDateTime(TimeOnly.MinValue)); enrollmentDataInResponse.Attributes.GraduatedAt.Should().Be(existingEnrollment.GraduatedAt!.Value.ToDateTime(TimeOnly.MinValue)); enrollmentDataInResponse.Attributes.HasGraduated.Should().Be(existingEnrollment.HasGraduated); @@ -239,10 +239,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => enrollmentInDatabase.GraduatedAt.Should().Be(existingEnrollment.GraduatedAt); enrollmentInDatabase.HasGraduated.Should().Be(existingEnrollment.HasGraduated); - enrollmentInDatabase.Student.ShouldNotBeNull(); + enrollmentInDatabase.Student.Should().NotBeNull(); enrollmentInDatabase.Student.Id.Should().Be(existingStudent.Id); - enrollmentInDatabase.Course.ShouldNotBeNull(); + enrollmentInDatabase.Course.Should().NotBeNull(); enrollmentInDatabase.Course.Id.Should().Be(existingCourse.Id); }); } diff --git a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs index 936ee0e094..ce8c6e2f2d 100644 --- a/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ClientIdGenerationModes/ClientIdGenerationModesTests.cs @@ -61,7 +61,7 @@ public async Task Cannot_create_resource_without_ID_when_supplying_ID_is_require error.Status.Should().Be("422"); error.Title.Should().Be("Failed to deserialize request body: The 'id' element is invalid."); error.Detail.Should().BeNull(); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); } @@ -126,7 +126,7 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_allowed() GamePrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostGameAsync(requestBody)); // Assert - document.ShouldNotBeNull(); + document.Should().NotBeNull(); document.Data.Id.Should().NotBe(Guid.Empty); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -243,7 +243,7 @@ public async Task Can_create_resource_without_ID_when_supplying_ID_is_forbidden( PlayerGroupPrimaryResponseDocument? document = await ApiResponse.TranslateAsync(async () => await apiClient.PostPlayerGroupAsync(requestBody)); // Assert - document.ShouldNotBeNull(); + document.Should().NotBeNull(); document.Data.Id.Should().NotBeNullOrEmpty(); long newPlayerGroupId = long.Parse(document.Data.Id); diff --git a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs index fa7f6c4161..c3473db26b 100644 --- a/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs @@ -78,7 +78,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); - response.Result.ShouldNotBeNull(); + response.Result.Should().NotBeNull(); } [Fact] @@ -135,7 +135,7 @@ public async Task Returns_no_ETag_for_POST_request() response.Headers.Should().NotContainKey(HeaderNames.ETag); - response.Result.ShouldNotBeNull(); + response.Result.Should().NotBeNull(); } [Fact] @@ -199,7 +199,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => eTagHeaderValues.Should().HaveCount(1); eTagHeaderValues[0].Should().Match("\"*\""); - response.Result.ShouldNotBeNull(); + response.Result.Should().NotBeNull(); } public void Dispose() diff --git a/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs index 7057fde4dd..48a659cac5 100644 --- a/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/HeaderTests.cs @@ -52,7 +52,7 @@ public async Task Returns_Location_for_post_resource_request() // Assert response.StatusCode.Should().Be((int)HttpStatusCode.Created); - response.Result.ShouldNotBeNull(); + response.Result.Should().NotBeNull(); string[] locationHeaderValues = response.Headers.Should().ContainKey(HeaderNames.Location).WhoseValue.ToArray(); locationHeaderValues.Should().HaveCount(1); diff --git a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index 0ac8d07373..88e33ae2dd 100644 --- a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -63,7 +63,7 @@ public async Task Cannot_exceed_length_constraint(string firstName) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/firstName"); } @@ -100,7 +100,7 @@ public async Task Cannot_exceed_string_length_constraint(string userName) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); } @@ -135,7 +135,7 @@ public async Task Cannot_violate_regular_expression_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("Only letters are allowed."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); } @@ -170,7 +170,7 @@ public async Task Cannot_use_invalid_credit_card_number() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The CreditCard field is not a valid credit card number."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/creditCard"); } @@ -205,7 +205,7 @@ public async Task Cannot_use_invalid_email_address() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The Email field is not a valid e-mail address."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/email"); } @@ -243,7 +243,7 @@ public async Task Cannot_exceed_min_length_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/password"); } @@ -280,7 +280,7 @@ public async Task Cannot_exceed_max_length_constraint() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/password"); } @@ -319,7 +319,7 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/age"); } @@ -354,7 +354,7 @@ public async Task Cannot_use_relative_url() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); } @@ -391,7 +391,7 @@ public async Task Cannot_exceed_collection_length_constraint(int length) ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/tags"); } @@ -426,7 +426,7 @@ public async Task Cannot_use_non_allowed_value() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/countryCode"); } @@ -461,7 +461,7 @@ public async Task Cannot_use_denied_value() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/planet"); } @@ -496,7 +496,7 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() ErrorObject errorObject = document.Errors.First(); errorObject.Title.Should().Be("Input validation failed."); errorObject.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); - errorObject.Source.ShouldNotBeNull(); + errorObject.Source.Should().NotBeNull(); errorObject.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs index 2557c39360..f663d55180 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs @@ -54,13 +54,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(nodes[1].Name); attributes.Comment.Should().Be(nodes[1].Comment); }); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); } @@ -95,13 +95,13 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(node.Children.ElementAt(1).Name); attributes.Comment.Should().Be(node.Children.ElementAt(1).Comment); }); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); } @@ -135,9 +135,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(1); - response.Links.ShouldNotBeNull(); + response.Links.Should().NotBeNull(); response.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); } @@ -160,7 +160,7 @@ public async Task Cannot_use_empty_filter() ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; exception.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); exception.Message.Should().Be("HTTP 400: The query string is invalid."); - exception.Result.Links.ShouldNotBeNull(); + exception.Result.Links.Should().NotBeNull(); exception.Result.Links.Describedby.Should().Be("/swagger/v1/swagger.json"); exception.Result.Errors.Should().HaveCount(1); @@ -168,7 +168,7 @@ public async Task Cannot_use_empty_filter() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'filter' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("filter"); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs index fa799f3f67..e2c25c4f80 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs @@ -153,14 +153,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NullableNodeSecondaryResponseDocument response = await apiClient.GetNodeParentAsync(node.StringId!, queryString); // Assert - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); response.Included.Should().HaveCount(1); response.Included.OfType().Should().ContainSingle(nodeData => nodeData.Id == node.Parent.Parent.StringId).Subject.With(nodeData => { - nodeData.Attributes.ShouldNotBeNull(); + nodeData.Attributes.Should().NotBeNull(); nodeData.Attributes.Name.Should().Be(node.Parent.Parent.Name); }); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs index d04d400095..a78be7a19f 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs @@ -52,7 +52,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } @@ -119,7 +119,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); - response.Meta.ShouldNotBeNull(); + response.Meta.Should().NotBeNull(); response.Meta.Should().ContainKey("total").WhoseValue.Should().Be(3); } @@ -148,7 +148,7 @@ public async Task Cannot_use_empty_page_size() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'page[size]' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[size]"); } @@ -177,7 +177,7 @@ public async Task Cannot_use_empty_page_number() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'page[number]' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("page[number]"); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs index 201517cdfc..44a11b217f 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs @@ -147,7 +147,7 @@ public async Task Cannot_use_empty_sort() error.Status.Should().Be("400"); error.Title.Should().Be("Missing query string parameter value."); error.Detail.Should().Be("Missing value for 'sort' query string parameter."); - error.Source.ShouldNotBeNull(); + error.Source.Should().NotBeNull(); error.Source.Parameter.Should().Be("sort"); } diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs index c2f1951f72..85cf301088 100644 --- a/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().Be(node.Name); attributes.Comment.Should().BeNull(); @@ -85,11 +85,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Id.Should().Be(node.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Comment); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.Parent.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Parent.Should().NotBeNull(); response.Data.Relationships.Children.Should().BeNull(); } @@ -122,16 +122,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); - response.Data.ElementAt(0).Attributes.ShouldNotBeNull().With(attributes => + response.Data.ElementAt(0).Attributes.RefShould().NotBeNull().And.Subject.With(attributes => { attributes.Name.Should().BeNull(); attributes.Comment.Should().Be(node.Children.ElementAt(0).Comment); }); - response.Data.ElementAt(0).Relationships.ShouldNotBeNull().With(relationships => + response.Data.ElementAt(0).Relationships.RefShould().NotBeNull().And.Subject.With(relationships => { relationships.Parent.Should().BeNull(); - relationships.Children.ShouldNotBeNull(); + relationships.Children.Should().NotBeNull(); }); } @@ -160,14 +160,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NullableNodeSecondaryResponseDocument response = await apiClient.GetNodeParentAsync(node.StringId!, queryString); // Assert - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Parent.Comment); - response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); response.Data.Relationships.Parent.Should().BeNull(); - response.Data.Relationships.Children.ShouldNotBeNull(); + response.Data.Relationships.Children.Should().NotBeNull(); } [Fact] diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs index 13a333759d..145b058101 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/CreateResourceTests.cs @@ -86,18 +86,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WriteOnlyChannelPrimaryResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostWriteOnlyChannelAsync(requestBody, queryString)); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(newChannel.Name); response.Data.Attributes.IsCommercial.Should().BeNull(); response.Data.Attributes.IsAdultOnly.Should().BeNull(); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().HaveCount(1); response.Data.Relationships.AudioStreams.Data.ElementAt(0).Id.Should().Be(existingAudioStream.StringId); @@ -106,18 +106,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingVideoStream.StringId).Subject.With( streamData => { - streamData.Attributes.ShouldNotBeNull(); + streamData.Attributes.Should().NotBeNull(); streamData.Attributes.BytesTransmitted.Should().Be((long?)existingVideoStream.BytesTransmitted); }); response.Included.OfType().Should().ContainSingle(streamData => streamData.Id == existingAudioStream.StringId).Subject.With( streamData => { - streamData.Attributes.ShouldNotBeNull(); + streamData.Attributes.Should().NotBeNull(); streamData.Attributes.BytesTransmitted.Should().Be((long?)existingAudioStream.BytesTransmitted); }); - long newChannelId = long.Parse(response.Data.Id.ShouldNotBeNull()); + long newChannelId = long.Parse(response.Data.Id.Should().NotBeNull().And.Subject); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -136,7 +136,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().BeNull(); channelInDatabase.IsAdultOnly.Should().Be(newChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); channelInDatabase.AudioStreams.Should().HaveCount(1); diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs index 10bbb884ca..e9c3b3198a 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchRelationshipTests.cs @@ -45,7 +45,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamIdentifierResponseDocument response = await apiClient.GetReadOnlyChannelVideoStreamRelationshipAsync(channel.StringId!); // Assert - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.VideoStream.StringId); } diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs index 7c149bfc3b..9fc26c930a 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/FetchResourceTests.cs @@ -49,29 +49,29 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(2); ReadOnlyChannelDataInResponse channel1 = response.Data.Single(channel => channel.Id == channels.ElementAt(0).StringId); - channel1.Attributes.ShouldNotBeNull(); + channel1.Attributes.Should().NotBeNull(); channel1.Attributes.Name.Should().Be(channels[0].Name); channel1.Attributes.IsCommercial.Should().Be(channels[0].IsCommercial); channel1.Attributes.IsAdultOnly.Should().Be(channels[0].IsAdultOnly); - channel1.Relationships.ShouldNotBeNull(); - channel1.Relationships.VideoStream.ShouldNotBeNull(); + channel1.Relationships.Should().NotBeNull(); + channel1.Relationships.VideoStream.Should().NotBeNull(); channel1.Relationships.VideoStream.Data.Should().BeNull(); - channel1.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel1.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); channel1.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - channel1.Relationships.AudioStreams.ShouldNotBeNull(); + channel1.Relationships.AudioStreams.Should().NotBeNull(); channel1.Relationships.AudioStreams.Data.Should().BeNull(); ReadOnlyChannelDataInResponse channel2 = response.Data.Single(channel => channel.Id == channels.ElementAt(1).StringId); - channel2.Attributes.ShouldNotBeNull(); + channel2.Attributes.Should().NotBeNull(); channel2.Attributes.Name.Should().Be(channels[1].Name); channel2.Attributes.IsCommercial.Should().Be(channels[1].IsCommercial); channel2.Attributes.IsAdultOnly.Should().Be(channels[1].IsAdultOnly); - channel2.Relationships.ShouldNotBeNull(); - channel2.Relationships.VideoStream.ShouldNotBeNull(); + channel2.Relationships.Should().NotBeNull(); + channel2.Relationships.VideoStream.Should().NotBeNull(); channel2.Relationships.VideoStream.Data.Should().BeNull(); - channel2.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channel2.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); channel2.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - channel2.Relationships.AudioStreams.ShouldNotBeNull(); + channel2.Relationships.AudioStreams.Should().NotBeNull(); channel2.Relationships.AudioStreams.Data.Should().BeNull(); } @@ -95,18 +95,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => ReadOnlyChannelPrimaryResponseDocument response = await apiClient.GetReadOnlyChannelAsync(channel.StringId!); // Assert - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(channel.Name); response.Data.Attributes.IsCommercial.Should().Be(channel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().Be(channel.IsAdultOnly); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Should().BeNull(); - response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeNull(); } @@ -154,9 +154,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext => DataStreamSecondaryResponseDocument response = await apiClient.GetReadOnlyChannelVideoStreamAsync(channel.StringId!); // Assert - response.Data.ShouldNotBeNull(); + response.Data.Should().NotBeNull(); response.Data.Id.Should().Be(channel.VideoStream.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.BytesTransmitted.Should().Be((long?)channel.VideoStream.BytesTransmitted); } @@ -207,11 +207,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Should().HaveCount(2); DataStreamDataInResponse audioStream1 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(0).StringId); - audioStream1.Attributes.ShouldNotBeNull(); + audioStream1.Attributes.Should().NotBeNull(); audioStream1.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(0).BytesTransmitted); DataStreamDataInResponse audioStream2 = response.Data.Single(autoStream => autoStream.Id == channel.AudioStreams.ElementAt(1).StringId); - audioStream2.Attributes.ShouldNotBeNull(); + audioStream2.Attributes.Should().NotBeNull(); audioStream2.Attributes.BytesTransmitted.Should().Be((long?)channel.AudioStreams.ElementAt(1).BytesTransmitted); } diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs index 91daf96233..60d20f3281 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -70,7 +70,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // @formatter:keep_existing_linebreaks restore // @formatter:wrap_chained_method_calls restore - channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Should().NotBeNull(); channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingVideoStream.Id); }); } diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs index 8e8b0a5eb6..dee210bc36 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateResourceTests.cs @@ -93,19 +93,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WriteOnlyChannelPrimaryResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, requestBody, queryString)); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Id.Should().Be(existingChannel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(newChannelName); response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().BeNull(); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.Data.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Data.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Id.Should().Be(existingVideoStream.StringId); response.Data.Relationships.UltraHighDefinitionVideoStream.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeEmpty(); response.Included.Should().HaveCount(1); @@ -129,7 +129,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingVideoStream.Id); channelInDatabase.UltraHighDefinitionVideoStream.Should().BeNull(); @@ -170,19 +170,19 @@ await _testContext.RunOnDatabaseAsync(async dbContext => WriteOnlyChannelPrimaryResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PatchWriteOnlyChannelAsync(existingChannel.StringId!, requestBody)); - response.ShouldNotBeNull(); + response.Should().NotBeNull(); response.Data.Id.Should().Be(existingChannel.StringId); - response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Should().NotBeNull(); response.Data.Attributes.Name.Should().Be(existingChannel.Name); response.Data.Attributes.IsCommercial.Should().Be(existingChannel.IsCommercial); response.Data.Attributes.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - response.Data.Relationships.ShouldNotBeNull(); - response.Data.Relationships.VideoStream.ShouldNotBeNull(); + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.VideoStream.Should().NotBeNull(); response.Data.Relationships.VideoStream.Data.Should().BeNull(); - response.Data.Relationships.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + response.Data.Relationships.UltraHighDefinitionVideoStream.Should().NotBeNull(); response.Data.Relationships.UltraHighDefinitionVideoStream.Data.Should().BeNull(); - response.Data.Relationships.AudioStreams.ShouldNotBeNull(); + response.Data.Relationships.AudioStreams.Should().NotBeNull(); response.Data.Relationships.AudioStreams.Data.Should().BeNull(); await _testContext.RunOnDatabaseAsync(async dbContext => @@ -203,10 +203,10 @@ await _testContext.RunOnDatabaseAsync(async dbContext => channelInDatabase.IsCommercial.Should().Be(existingChannel.IsCommercial); channelInDatabase.IsAdultOnly.Should().Be(existingChannel.IsAdultOnly); - channelInDatabase.VideoStream.ShouldNotBeNull(); + channelInDatabase.VideoStream.Should().NotBeNull(); channelInDatabase.VideoStream.Id.Should().Be(existingChannel.VideoStream.Id); - channelInDatabase.UltraHighDefinitionVideoStream.ShouldNotBeNull(); + channelInDatabase.UltraHighDefinitionVideoStream.Should().NotBeNull(); channelInDatabase.UltraHighDefinitionVideoStream.Id.Should().Be(existingChannel.UltraHighDefinitionVideoStream.Id); channelInDatabase.AudioStreams.Should().HaveCount(2); From 73e9e335d44c1fc4ccba03c6c740077c6b202281 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 14:28:38 +0100 Subject: [PATCH 8/9] Simplify some assertions (#1695) --- .../Creating/AtomicCreateResourceTests.cs | 26 +++---- ...reateResourceWithClientGeneratedIdTests.cs | 8 +-- ...eateResourceWithToManyRelationshipTests.cs | 16 ++--- ...reateResourceWithToOneRelationshipTests.cs | 16 ++--- .../Deleting/AtomicDeleteResourceTests.cs | 14 ++-- .../Mixed/AtomicRequestBodyTests.cs | 8 +-- .../Mixed/MaximumOperationsPerRequestTests.cs | 2 +- .../AtomicAddToToManyRelationshipTests.cs | 34 ++++----- ...AtomicRemoveFromToManyRelationshipTests.cs | 32 ++++----- .../AtomicReplaceToManyRelationshipTests.cs | 34 ++++----- .../AtomicUpdateToOneRelationshipTests.cs | 32 ++++----- .../AtomicReplaceToManyRelationshipTests.cs | 18 ++--- .../Resources/AtomicUpdateResourceTests.cs | 46 ++++++------- .../AtomicUpdateToOneRelationshipTests.cs | 18 ++--- .../ExceptionHandlerTests.cs | 25 +------ .../NamingConventions/PascalCasingTests.cs | 7 +- .../ReadWrite/Creating/CreateResourceTests.cs | 28 ++++---- ...reateResourceWithClientGeneratedIdTests.cs | 10 +-- ...eateResourceWithToManyRelationshipTests.cs | 18 ++--- ...reateResourceWithToOneRelationshipTests.cs | 18 ++--- .../AddToToManyRelationshipTests.cs | 20 +++--- .../RemoveFromToManyRelationshipTests.cs | 20 +++--- .../ReplaceToManyRelationshipTests.cs | 18 ++--- .../UpdateToOneRelationshipTests.cs | 16 ++--- .../ReplaceToManyRelationshipTests.cs | 16 ++--- .../Updating/Resources/UpdateResourceTests.cs | 34 ++++----- .../Resources/UpdateToOneRelationshipTests.cs | 16 ++--- .../FluentAssertionsExtensions.cs | 49 ------------- ...tionsExtensions.cs => FluentExtensions.cs} | 46 ++++++++++--- .../FluentMetaExtensions.cs | 69 +++++++++++++++++++ 30 files changed, 370 insertions(+), 344 deletions(-) delete mode 100644 test/TestBuildingBlocks/FluentAssertionsExtensions.cs rename test/TestBuildingBlocks/{ObjectAssertionsExtensions.cs => FluentExtensions.cs} (57%) create mode 100644 test/TestBuildingBlocks/FluentMetaExtensions.cs diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs index c4f70fe60d..8b0090fe8e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceTests.cs @@ -261,7 +261,7 @@ public async Task Cannot_create_resource_with_unknown_attribute() error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'playlists'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -366,7 +366,7 @@ public async Task Cannot_create_resource_with_unknown_relationship() error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'lyrics'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -478,7 +478,7 @@ public async Task Cannot_create_resource_with_client_generated_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -513,7 +513,7 @@ public async Task Cannot_create_resource_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -551,7 +551,7 @@ public async Task Cannot_create_resource_for_ref_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -585,7 +585,7 @@ public async Task Cannot_create_resource_for_missing_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -620,7 +620,7 @@ public async Task Cannot_create_resource_for_null_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -667,7 +667,7 @@ public async Task Cannot_create_resource_for_array_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -707,7 +707,7 @@ public async Task Cannot_create_resource_for_missing_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -745,7 +745,7 @@ public async Task Cannot_create_resource_for_unknown_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -790,7 +790,7 @@ public async Task Cannot_create_resource_with_readonly_attribute() error.Detail.Should().Be("Attribute 'isArchived' on resource type 'playlists' is read-only."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/isArchived"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -832,7 +832,7 @@ public async Task Cannot_create_resource_with_incompatible_attribute_value() error.Detail.Should().Be("Failed to convert attribute 'bornAt' with value '12345' of type 'Number' to type 'DateTimeOffset'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/bornAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -985,6 +985,6 @@ public async Task Cannot_assign_attribute_with_blocked_capability() error.Detail.Should().Be("The attribute 'createdAt' on resource type 'lyrics' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/createdAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs index 8675f54c3d..0d8f7b14a7 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithClientGeneratedIdTests.cs @@ -247,7 +247,7 @@ public async Task Cannot_create_resource_for_missing_client_generated_ID(ClientI error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -356,7 +356,7 @@ public async Task Cannot_create_resource_for_incompatible_ID(ClientIdGenerationM error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int32'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -456,7 +456,7 @@ public async Task Cannot_create_resource_with_local_ID(ClientIdGenerationMode mo error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/lid"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -501,6 +501,6 @@ public async Task Cannot_create_resource_for_ID_and_local_ID(ClientIdGenerationM error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs index 775b6d2197..0b86e91ddf 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToManyRelationshipTests.cs @@ -238,7 +238,7 @@ public async Task Cannot_create_for_missing_relationship_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -290,7 +290,7 @@ public async Task Cannot_create_for_unknown_relationship_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -341,7 +341,7 @@ public async Task Cannot_create_for_missing_relationship_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -467,7 +467,7 @@ public async Task Cannot_create_on_relationship_type_mismatch() error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -590,7 +590,7 @@ public async Task Cannot_create_with_missing_data_in_OneToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -635,7 +635,7 @@ public async Task Cannot_create_with_null_data_in_ManyToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -682,7 +682,7 @@ public async Task Cannot_create_with_object_data_in_ManyToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -734,6 +734,6 @@ public async Task Cannot_assign_relationship_with_blocked_capability() error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/occursIn"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs index ff60ccbf87..a140a52322 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Creating/AtomicCreateResourceWithToOneRelationshipTests.cs @@ -304,7 +304,7 @@ public async Task Cannot_create_for_null_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -348,7 +348,7 @@ public async Task Cannot_create_for_missing_data_in_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -400,7 +400,7 @@ public async Task Cannot_create_for_array_data_in_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -448,7 +448,7 @@ public async Task Cannot_create_for_missing_relationship_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -497,7 +497,7 @@ public async Task Cannot_create_for_unknown_relationship_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -545,7 +545,7 @@ public async Task Cannot_create_for_missing_relationship_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -651,7 +651,7 @@ public async Task Cannot_create_on_relationship_type_mismatch() error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -781,6 +781,6 @@ public async Task Cannot_assign_relationship_with_blocked_capability() error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/language"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs index c8c00b1a54..a330577dbd 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Deleting/AtomicDeleteResourceTests.cs @@ -355,7 +355,7 @@ public async Task Cannot_delete_resource_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -389,7 +389,7 @@ public async Task Cannot_delete_resource_for_missing_ref_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -427,7 +427,7 @@ public async Task Cannot_delete_resource_for_missing_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -466,7 +466,7 @@ public async Task Cannot_delete_resource_for_unknown_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -504,7 +504,7 @@ public async Task Cannot_delete_resource_for_missing_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -586,7 +586,7 @@ public async Task Cannot_delete_resource_for_incompatible_ID() error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int64'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -626,6 +626,6 @@ public async Task Cannot_delete_resource_for_ID_and_local_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs index e4d67f457f..abc4525b60 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/AtomicRequestBodyTests.cs @@ -64,7 +64,7 @@ public async Task Cannot_process_for_null_request_body() error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -117,7 +117,7 @@ public async Task Cannot_process_for_missing_operations_array() error.Title.Should().Be("Failed to deserialize request body: No operations found."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -144,7 +144,7 @@ public async Task Cannot_process_empty_operations_array() error.Title.Should().Be("Failed to deserialize request body: No operations found."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -175,7 +175,7 @@ public async Task Cannot_process_null_operation() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs index 0173e1c6d4..b18c4991db 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Mixed/MaximumOperationsPerRequestTests.cs @@ -73,7 +73,7 @@ public async Task Cannot_process_more_operations_than_maximum() error.Detail.Should().Be("The number of operations in this request (3) is higher than the maximum of 2."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs index 5ddc0d55fd..419c8e5b16 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicAddToToManyRelationshipTests.cs @@ -70,7 +70,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Relationship 'ownedBy' is not a to-many relationship."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -265,7 +265,7 @@ public async Task Cannot_add_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -304,7 +304,7 @@ public async Task Cannot_add_for_missing_type_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -344,7 +344,7 @@ public async Task Cannot_add_for_unknown_type_in_ref() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -383,7 +383,7 @@ public async Task Cannot_add_for_missing_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -482,7 +482,7 @@ public async Task Cannot_add_for_ID_and_local_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -521,7 +521,7 @@ public async Task Cannot_add_for_missing_relationship_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -561,7 +561,7 @@ public async Task Cannot_add_for_unknown_relationship_in_ref() error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -609,7 +609,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -658,7 +658,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -709,7 +709,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -756,7 +756,7 @@ public async Task Cannot_add_for_missing_type_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -804,7 +804,7 @@ public async Task Cannot_add_for_unknown_type_in_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -851,7 +851,7 @@ public async Task Cannot_add_for_missing_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -900,7 +900,7 @@ public async Task Cannot_add_for_ID_and_local_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1029,7 +1029,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1132,6 +1132,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be added to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs index a914e59ac3..98d954c910 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicRemoveFromToManyRelationshipTests.cs @@ -70,7 +70,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Relationship 'ownedBy' is not a to-many relationship."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -264,7 +264,7 @@ public async Task Cannot_remove_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -303,7 +303,7 @@ public async Task Cannot_remove_for_missing_type_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -343,7 +343,7 @@ public async Task Cannot_remove_for_unknown_type_in_ref() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -382,7 +382,7 @@ public async Task Cannot_remove_for_missing_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -481,7 +481,7 @@ public async Task Cannot_remove_for_ID_and_local_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -521,7 +521,7 @@ public async Task Cannot_remove_for_unknown_relationship_in_ref() error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -569,7 +569,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -618,7 +618,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -669,7 +669,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -716,7 +716,7 @@ public async Task Cannot_remove_for_missing_type_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -764,7 +764,7 @@ public async Task Cannot_remove_for_unknown_type_in_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -811,7 +811,7 @@ public async Task Cannot_remove_for_missing_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -860,7 +860,7 @@ public async Task Cannot_remove_for_ID_and_local_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -989,7 +989,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1093,6 +1093,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be removed from."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs index 38d2d1aac0..3653763f60 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicReplaceToManyRelationshipTests.cs @@ -299,7 +299,7 @@ public async Task Cannot_replace_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -338,7 +338,7 @@ public async Task Cannot_replace_for_missing_type_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -378,7 +378,7 @@ public async Task Cannot_replace_for_unknown_type_in_ref() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -417,7 +417,7 @@ public async Task Cannot_replace_for_missing_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -533,7 +533,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int16'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -574,7 +574,7 @@ public async Task Cannot_replace_for_ID_and_local_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -614,7 +614,7 @@ public async Task Cannot_replace_for_unknown_relationship_in_ref() error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -662,7 +662,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -711,7 +711,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -762,7 +762,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -809,7 +809,7 @@ public async Task Cannot_replace_for_missing_type_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -857,7 +857,7 @@ public async Task Cannot_replace_for_unknown_type_in_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -904,7 +904,7 @@ public async Task Cannot_replace_for_missing_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -953,7 +953,7 @@ public async Task Cannot_replace_for_ID_and_local_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1082,7 +1082,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1138,7 +1138,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1191,6 +1191,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs index 3d543a15f6..a079f9d829 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Relationships/AtomicUpdateToOneRelationshipTests.cs @@ -552,7 +552,7 @@ public async Task Cannot_create_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -591,7 +591,7 @@ public async Task Cannot_create_for_missing_type_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -631,7 +631,7 @@ public async Task Cannot_create_for_unknown_type_in_ref() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -670,7 +670,7 @@ public async Task Cannot_create_for_missing_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -778,7 +778,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -819,7 +819,7 @@ public async Task Cannot_create_for_ID_and_local_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -859,7 +859,7 @@ public async Task Cannot_create_for_unknown_relationship_in_ref() error.Detail.Should().Be($"Relationship '{Unknown.Relationship}' does not exist on resource type 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -907,7 +907,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -963,7 +963,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1007,7 +1007,7 @@ public async Task Cannot_create_for_missing_type_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1052,7 +1052,7 @@ public async Task Cannot_create_for_unknown_type_in_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1096,7 +1096,7 @@ public async Task Cannot_create_for_missing_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1142,7 +1142,7 @@ public async Task Cannot_create_for_ID_and_local_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1250,7 +1250,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Failed to convert 'invalid-guid' of type 'String' to type 'Guid'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1303,7 +1303,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1356,6 +1356,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/relationship"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs index 31a2b61512..32db3a5221 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicReplaceToManyRelationshipTests.cs @@ -337,7 +337,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -391,7 +391,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -447,7 +447,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -499,7 +499,7 @@ public async Task Cannot_replace_for_missing_type_in_relationship_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/tracks/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -552,7 +552,7 @@ public async Task Cannot_replace_for_unknown_type_in_relationship_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -604,7 +604,7 @@ public async Task Cannot_replace_for_missing_ID_in_relationship_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -658,7 +658,7 @@ public async Task Cannot_replace_for_ID_and_local_ID_relationship_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -797,7 +797,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers' of relationship 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/performers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -858,6 +858,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'occursIn' on resource type 'musicTracks' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/occursIn"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs index 2e97812c19..8bf1ae451b 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateResourceTests.cs @@ -208,7 +208,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'musicTracks'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -321,7 +321,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'musicTracks'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -639,7 +639,7 @@ public async Task Cannot_update_resource_for_href_element() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/href"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -745,7 +745,7 @@ public async Task Cannot_update_resource_for_missing_type_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -794,7 +794,7 @@ public async Task Cannot_update_resource_for_missing_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -845,7 +845,7 @@ public async Task Cannot_update_resource_for_ID_and_local_ID_in_ref() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -879,7 +879,7 @@ public async Task Cannot_update_resource_for_missing_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -914,7 +914,7 @@ public async Task Cannot_update_resource_for_null_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -968,7 +968,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1012,7 +1012,7 @@ public async Task Cannot_update_resource_for_missing_type_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1056,7 +1056,7 @@ public async Task Cannot_update_resource_for_missing_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1102,7 +1102,7 @@ public async Task Cannot_update_resource_for_ID_and_local_ID_in_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1152,7 +1152,7 @@ public async Task Cannot_update_on_resource_type_mismatch_between_ref_and_data() error.Detail.Should().Be("Type 'playlists' is not convertible to type 'performers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1205,7 +1205,7 @@ public async Task Cannot_update_on_resource_ID_mismatch_between_ref_and_data() error.Detail.Should().Be($"Expected '{performerId1}' instead of '{performerId2}'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1255,7 +1255,7 @@ public async Task Cannot_update_on_resource_local_ID_mismatch_between_ref_and_da error.Detail.Should().Be("Expected 'local-1' instead of 'local-2'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/lid"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1307,7 +1307,7 @@ public async Task Cannot_update_on_mixture_of_ID_and_local_ID_between_ref_and_da error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1359,7 +1359,7 @@ public async Task Cannot_update_on_mixture_of_local_ID_and_ID_between_ref_and_da error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1404,7 +1404,7 @@ public async Task Cannot_update_resource_for_unknown_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1500,7 +1500,7 @@ public async Task Cannot_update_resource_for_incompatible_ID() error.Detail.Should().Be($"Failed to convert '{guid}' of type 'String' to type 'Int32'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/ref/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1551,7 +1551,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Attribute 'isArchived' on resource type 'playlists' is read-only."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/isArchived"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1602,7 +1602,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1653,7 +1653,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Failed to convert attribute 'bornAt' with value '123.45' of type 'Number' to type 'DateTimeOffset'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/bornAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1813,6 +1813,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The attribute 'createdAt' on resource type 'lyrics' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/attributes/createdAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs index 00133e29ea..a8c6881616 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/AtomicOperations/Updating/Resources/AtomicUpdateToOneRelationshipTests.cs @@ -613,7 +613,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -666,7 +666,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -727,7 +727,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -776,7 +776,7 @@ public async Task Cannot_create_for_missing_type_in_relationship_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/track/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -826,7 +826,7 @@ public async Task Cannot_create_for_unknown_type_in_relationship_data() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -875,7 +875,7 @@ public async Task Cannot_create_for_missing_ID_in_relationship_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -926,7 +926,7 @@ public async Task Cannot_create_for_ID_and_local_ID_in_relationship_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1044,7 +1044,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'playlists' is not convertible to type 'lyrics' of relationship 'lyric'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/lyric/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1102,6 +1102,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'language' on resource type 'lyrics' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/atomic:operations[0]/data/relationships/language"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs index 8a635c734f..35a5364938 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ExceptionHandling/ExceptionHandlerTests.cs @@ -109,20 +109,8 @@ public async Task Logs_and_produces_error_response_on_deserialization_failure() error.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); error.Title.Should().Be("Failed to deserialize request body: Unknown resource type found."); error.Detail.Should().Be("Resource type '' does not exist."); - - error.Meta.Should().ContainKey("requestBody").WhoseValue.With(value => - { - JsonElement element = value.Should().BeOfType().Subject; - element.GetString().Should().Be(requestBody); - }); - - error.Meta.Should().ContainKey("stackTrace").WhoseValue.With(value => - { - JsonElement element = value.Should().BeOfType().Subject; - IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); - - stackTraceLines.Should().NotBeEmpty(); - }); + error.Meta.Should().ContainRequestBody(requestBody); + error.Meta.Should().HaveStackTrace(); IReadOnlyList logMessages = loggerProvider.GetMessages(); logMessages.Should().BeEmpty(); @@ -157,14 +145,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.StatusCode.Should().Be(HttpStatusCode.InternalServerError); error.Title.Should().Be("An unhandled error occurred while processing this request."); error.Detail.Should().Be("Exception has been thrown by the target of an invocation."); - - error.Meta.Should().ContainKey("stackTrace").WhoseValue.With(value => - { - JsonElement element = value.Should().BeOfType().Subject; - IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); - - stackTraceLines.Should().ContainMatch("*ThrowingArticle*"); - }); + error.Meta.Should().HaveInStackTrace("*ThrowingArticle*"); responseDocument.Meta.Should().BeNull(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs index 1b630cdc92..9da9e4e520 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/NamingConventions/PascalCasingTests.cs @@ -1,5 +1,4 @@ using System.Net; -using System.Text.Json; using FluentAssertions; using JsonApiDotNetCore.Serialization.Objects; using TestBuildingBlocks; @@ -58,11 +57,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => responseDocument.Included[0].Relationships.Should().BeNull(); responseDocument.Included[0].Links.RefShould().NotBeNull().And.Subject.Self.Should().Be(link); - responseDocument.Meta.Should().ContainKey("Total").WhoseValue.With(value => - { - JsonElement element = value.Should().BeOfType().Subject; - element.GetInt32().Should().Be(2); - }); + responseDocument.Meta.Should().ContainTotal(2, "Total"); } [Fact] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs index de1623fb12..004fcb2121 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceTests.cs @@ -288,7 +288,7 @@ public async Task Cannot_create_resource_with_unknown_attribute() error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'workItems'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -375,7 +375,7 @@ public async Task Cannot_create_resource_with_unknown_relationship() error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'workItems'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -460,7 +460,7 @@ public async Task Cannot_create_resource_with_client_generated_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -511,7 +511,7 @@ public async Task Cannot_create_resource_for_null_request_body() error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -541,7 +541,7 @@ public async Task Cannot_create_resource_for_missing_data() error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -569,7 +569,7 @@ public async Task Cannot_create_resource_for_null_data() error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -603,7 +603,7 @@ public async Task Cannot_create_resource_for_array_data() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -636,7 +636,7 @@ public async Task Cannot_create_resource_for_missing_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -670,7 +670,7 @@ public async Task Cannot_create_resource_for_unknown_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -728,7 +728,7 @@ public async Task Cannot_create_on_resource_type_mismatch_between_url_and_body() error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'workItems'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -763,7 +763,7 @@ public async Task Cannot_create_resource_with_readonly_attribute() error.Detail.Should().Be("Attribute 'isDeprecated' on resource type 'workItemGroups' is read-only."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isDeprecated"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -787,7 +787,7 @@ public async Task Cannot_create_resource_for_broken_JSON_request_body() error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().StartWith("'{' is invalid after a property name."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -822,7 +822,7 @@ public async Task Cannot_create_resource_with_incompatible_attribute_value() error.Detail.Should().Be("Failed to convert attribute 'dueAt' with value 'not-a-valid-time' of type 'String' to type 'Nullable'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/dueAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -959,6 +959,6 @@ public async Task Cannot_assign_attribute_with_blocked_capability() error.Detail.Should().Be("The attribute 'isImportant' on resource type 'workItems' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isImportant"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs index 5d8e5041c9..681dc034c2 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithClientGeneratedIdTests.cs @@ -338,7 +338,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -381,7 +381,7 @@ public async Task Cannot_create_resource_with_client_generated_zero_guid_ID(Clie error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -424,7 +424,7 @@ public async Task Cannot_create_resource_with_client_generated_empty_guid_ID(Cli error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -519,7 +519,7 @@ public async Task Cannot_create_resource_with_client_generated_zero_long_ID(Clie error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] @@ -563,7 +563,7 @@ public async Task Cannot_create_resource_with_client_generated_empty_long_ID(Cli error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Theory] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs index ef2c3ee216..9323133ae1 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToManyRelationshipTests.cs @@ -362,7 +362,7 @@ public async Task Cannot_create_for_missing_relationship_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -407,7 +407,7 @@ public async Task Cannot_create_for_unknown_relationship_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -451,7 +451,7 @@ public async Task Cannot_create_for_missing_relationship_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -560,7 +560,7 @@ public async Task Cannot_create_on_relationship_type_mismatch() error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'subscribers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -663,7 +663,7 @@ public async Task Cannot_create_with_missing_data_in_OneToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -701,7 +701,7 @@ public async Task Cannot_create_with_null_data_in_ManyToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -741,7 +741,7 @@ public async Task Cannot_create_with_object_data_in_ManyToMany_relationship() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -789,7 +789,7 @@ public async Task Cannot_create_resource_with_local_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/lid"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -834,6 +834,6 @@ public async Task Cannot_assign_relationship_with_blocked_capability() error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/items"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs index 362e9ec958..42c63fd357 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Creating/CreateResourceWithToOneRelationshipTests.cs @@ -337,7 +337,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -382,7 +382,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -435,7 +435,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -476,7 +476,7 @@ public async Task Cannot_create_for_missing_relationship_type() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -518,7 +518,7 @@ public async Task Cannot_create_for_unknown_relationship_type() error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -559,7 +559,7 @@ public async Task Cannot_create_for_missing_relationship_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -644,7 +644,7 @@ public async Task Cannot_create_on_relationship_type_mismatch() error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -760,7 +760,7 @@ public async Task Cannot_create_resource_with_local_ID() error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/lid"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -802,6 +802,6 @@ public async Task Cannot_assign_relationship_with_blocked_capability() error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/group"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs index e2f3c8933b..2da2983765 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/AddToToManyRelationshipTests.cs @@ -58,7 +58,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this endpoint."); error.Detail.Should().Be("Relationship 'assignee' is not a to-many relationship."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -239,7 +239,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -281,7 +281,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -324,7 +324,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -366,7 +366,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -684,7 +684,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -802,7 +802,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -838,7 +838,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -876,7 +876,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1020,6 +1020,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be added to."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be added to."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs index c9b948ca34..c8499bb95e 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/RemoveFromToManyRelationshipTests.cs @@ -69,7 +69,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Only to-many relationships can be targeted through this endpoint."); error.Detail.Should().Be("Relationship 'assignee' is not a to-many relationship."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -351,7 +351,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -394,7 +394,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -437,7 +437,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -479,7 +479,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -797,7 +797,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -917,7 +917,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -953,7 +953,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -991,7 +991,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1138,7 +1138,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be removed from."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be removed from."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs index 7a8c0cfea1..5f4836cf24 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/ReplaceToManyRelationshipTests.cs @@ -268,7 +268,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -310,7 +310,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -353,7 +353,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -395,7 +395,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -710,7 +710,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'userAccounts' is not convertible to type 'workTags' of relationship 'tags'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -795,7 +795,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -831,7 +831,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -869,7 +869,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1099,6 +1099,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs index e05fda291f..bff2522997 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Relationships/UpdateToOneRelationshipTests.cs @@ -304,7 +304,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -339,7 +339,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -383,7 +383,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -422,7 +422,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -462,7 +462,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -501,7 +501,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -735,7 +735,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -853,6 +853,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Relationship cannot be assigned."); error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs index da33ab6dc5..f8317f14ec 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/ReplaceToManyRelationshipTests.cs @@ -443,7 +443,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -497,7 +497,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -550,7 +550,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -697,7 +697,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'subscribers'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers/data[0]/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -805,7 +805,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/subscribers"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -852,7 +852,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -901,7 +901,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/tags/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1183,6 +1183,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'items' on resource type 'workItemGroups' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/items"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs index ee43e42a0d..428c4a30d3 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateResourceTests.cs @@ -125,7 +125,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Attribute 'doesNotExist' does not exist on resource type 'userAccounts'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -225,7 +225,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Relationship 'doesNotExist' does not exist on resource type 'userAccounts'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/doesNotExist"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -706,7 +706,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: Expected an object, instead of 'null'."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -744,7 +744,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body: The 'data' element is required."); error.Detail.Should().BeNull(); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -780,7 +780,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -823,7 +823,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -862,7 +862,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -902,7 +902,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -941,7 +941,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1046,7 +1046,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'workItems'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1086,7 +1086,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Expected '{existingWorkItems[1].StringId}' instead of '{existingWorkItems[0].StringId}'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1130,7 +1130,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Attribute 'isDeprecated' on resource type 'workItemGroups' is read-only."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isDeprecated"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1162,7 +1162,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().StartWith("Expected end of string, but instead reached end of data."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1206,7 +1206,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/id"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1248,7 +1248,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Title.Should().Be("Failed to deserialize request body."); error.Detail.Should().Be($"Failed to convert ID '{existingWorkItem.Id}' of type 'Number' to type 'String'."); error.Source.Should().BeNull(); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1296,7 +1296,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Match("Failed to convert attribute 'dueAt' with value '*start*end*' of type 'Object' to type 'Nullable'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/dueAt"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -1544,6 +1544,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The attribute 'isImportant' on resource type 'workItems' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/attributes/isImportant"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs index bd0cbd1943..07fedff2ad 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/ReadWrite/Updating/Resources/UpdateToOneRelationshipTests.cs @@ -480,7 +480,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -527,7 +527,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -582,7 +582,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -632,7 +632,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -683,7 +683,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be($"Resource type '{Unknown.ResourceType}' does not exist."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -733,7 +733,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().BeNull(); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -836,7 +836,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("Type 'rgbColors' is not convertible to type 'userAccounts' of relationship 'assignee'."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/assignee/data/type"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } [Fact] @@ -987,6 +987,6 @@ await _testContext.RunOnDatabaseAsync(async dbContext => error.Detail.Should().Be("The relationship 'group' on resource type 'workItems' cannot be assigned to."); error.Source.Should().NotBeNull(); error.Source.Pointer.Should().Be("/data/relationships/group"); - error.Meta.Should().ContainKey("requestBody").WhoseValue.Should().NotBeNull().And.Subject.ToString().Should().NotBeEmpty(); + error.Meta.Should().HaveRequestBody(); } } diff --git a/test/TestBuildingBlocks/FluentAssertionsExtensions.cs b/test/TestBuildingBlocks/FluentAssertionsExtensions.cs deleted file mode 100644 index 79e1ef7582..0000000000 --- a/test/TestBuildingBlocks/FluentAssertionsExtensions.cs +++ /dev/null @@ -1,49 +0,0 @@ -using FluentAssertions; -using FluentAssertions.Collections; -using FluentAssertions.Primitives; -using JetBrains.Annotations; -using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; - -// ReSharper disable UnusedMethodReturnValue.Global - -namespace TestBuildingBlocks; - -public static class FluentAssertionsExtensions -{ - // Workaround for source.Should().NotBeNull().And.Subject having declared type 'object'. - [System.Diagnostics.Contracts.Pure] - public static StrongReferenceTypeAssertions RefShould([SysNotNull] this T? actualValue) - where T : class - { - actualValue.Should().NotBeNull(); - return new StrongReferenceTypeAssertions(actualValue); - } - - public static AndConstraint OnlyContainKeys( - this GenericDictionaryAssertions source, params TKey[] expected) - where TCollection : IEnumerable> - where TAssertions : GenericDictionaryAssertions - { - return source.HaveCount(expected.Length).And.ContainKeys(expected); - } - - // Workaround for CS0854: An expression tree may not contain a call or invocation that uses optional arguments. - public static WhoseValueConstraint ContainKey2( - this GenericDictionaryAssertions source, TKey expected) - where TCollection : IEnumerable> - where TAssertions : GenericDictionaryAssertions - { - return source.ContainKey(expected); - } - - public static void With(this T subject, [InstantHandle] Action continuation) - { - continuation(subject); - } - - public sealed class StrongReferenceTypeAssertions(TReference subject) - : ReferenceTypeAssertions>(subject) - { - protected override string Identifier => "subject"; - } -} diff --git a/test/TestBuildingBlocks/ObjectAssertionsExtensions.cs b/test/TestBuildingBlocks/FluentExtensions.cs similarity index 57% rename from test/TestBuildingBlocks/ObjectAssertionsExtensions.cs rename to test/TestBuildingBlocks/FluentExtensions.cs index 47e08b69f1..1061a71765 100644 --- a/test/TestBuildingBlocks/ObjectAssertionsExtensions.cs +++ b/test/TestBuildingBlocks/FluentExtensions.cs @@ -6,11 +6,13 @@ using FluentAssertions.Numeric; using FluentAssertions.Primitives; using JetBrains.Annotations; +using SysNotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute; + +// ReSharper disable UnusedMethodReturnValue.Global namespace TestBuildingBlocks; -[PublicAPI] -public static class ObjectAssertionsExtensions +public static class FluentExtensions { private const decimal NumericPrecision = 0.00000000001M; @@ -69,12 +71,40 @@ private static string ToJsonString(JsonDocument document) return Encoding.UTF8.GetString(stream.ToArray()); } - /// - /// Asserts that a "meta" dictionary contains a single element named "total" with the specified value. - /// - [CustomAssertion] - public static void ContainTotal(this GenericDictionaryAssertions, string, object?> source, int expectedTotal) + // Workaround for source.Should().NotBeNull().And.Subject having declared type 'object'. + [System.Diagnostics.Contracts.Pure] + public static StrongReferenceTypeAssertions RefShould([SysNotNull] this T? actualValue) + where T : class + { + actualValue.Should().NotBeNull(); + return new StrongReferenceTypeAssertions(actualValue); + } + + public static AndConstraint OnlyContainKeys( + this GenericDictionaryAssertions source, params TKey[] expected) + where TCollection : IEnumerable> + where TAssertions : GenericDictionaryAssertions + { + return source.HaveCount(expected.Length).And.ContainKeys(expected); + } + + // Workaround for CS0854: An expression tree may not contain a call or invocation that uses optional arguments. + public static WhoseValueConstraint ContainKey2( + this GenericDictionaryAssertions source, TKey expected) + where TCollection : IEnumerable> + where TAssertions : GenericDictionaryAssertions + { + return source.ContainKey(expected); + } + + public static void With(this T subject, [InstantHandle] Action continuation) + { + continuation(subject); + } + + public sealed class StrongReferenceTypeAssertions(TReference subject) + : ReferenceTypeAssertions>(subject) { - source.ContainKey("total").WhoseValue.Should().BeOfType().Subject.GetInt32().Should().Be(expectedTotal); + protected override string Identifier => "subject"; } } diff --git a/test/TestBuildingBlocks/FluentMetaExtensions.cs b/test/TestBuildingBlocks/FluentMetaExtensions.cs new file mode 100644 index 0000000000..ff81bb47f0 --- /dev/null +++ b/test/TestBuildingBlocks/FluentMetaExtensions.cs @@ -0,0 +1,69 @@ +using System.Text.Json; +using FluentAssertions; +using FluentAssertions.Collections; + +namespace TestBuildingBlocks; + +public static class FluentMetaExtensions +{ + /// + /// Asserts that a "meta" dictionary contains a single element named "total" with the specified value. + /// + [CustomAssertion] +#pragma warning disable AV1553 // Do not use optional parameters with default value null for strings, collections or tasks + public static void ContainTotal(this GenericDictionaryAssertions, string, object?> source, int expected, + string? keyName = null) +#pragma warning restore AV1553 // Do not use optional parameters with default value null for strings, collections or tasks + { + JsonElement element = GetMetaJsonElement(source, keyName ?? "total"); + element.GetInt32().Should().Be(expected); + } + + /// + /// Asserts that a "meta" dictionary contains a single element named "requestBody" that isn't empty. + /// + [CustomAssertion] + public static void HaveRequestBody(this GenericDictionaryAssertions, string, object?> source) + { + JsonElement element = GetMetaJsonElement(source, "requestBody"); + element.ToString().Should().NotBeEmpty(); + } + + /// + /// Asserts that a "meta" dictionary contains a single element named "requestBody" with the specified value. + /// + [CustomAssertion] + public static void ContainRequestBody(this GenericDictionaryAssertions, string, object?> source, string expected) + { + JsonElement element = GetMetaJsonElement(source, "requestBody"); + element.GetString().Should().Be(expected); + } + + /// + /// Asserts that a "meta" dictionary contains a single element named "stackTrace" that isn't empty. + /// + [CustomAssertion] + public static void HaveStackTrace(this GenericDictionaryAssertions, string, object?> source) + { + JsonElement element = GetMetaJsonElement(source, "stackTrace"); + IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); + stackTraceLines.Should().NotBeEmpty(); + } + + /// + /// Asserts that a "meta" dictionary contains a single element named "stackTrace" that contains the specified pattern. + /// + [CustomAssertion] + public static void HaveInStackTrace(this GenericDictionaryAssertions, string, object?> source, string pattern) + { + JsonElement element = GetMetaJsonElement(source, "stackTrace"); + IEnumerable stackTraceLines = element.EnumerateArray().Select(token => token.GetString()); + stackTraceLines.Should().ContainMatch(pattern); + } + + private static JsonElement GetMetaJsonElement(GenericDictionaryAssertions, string, object?> source, string metaKey) + { + object? value = source.ContainKey(metaKey).WhoseValue; + return value.Should().BeOfType().Subject; + } +} From 61c6cd5c160a5ed163b92bcd00e87c778dac900f Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 2 Mar 2025 14:58:47 +0100 Subject: [PATCH 9/9] Rename type with FluentAssertions extension methods --- ...entAssertionExtensions.cs => FluentJsonElementExtensions.cs} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename test/TestBuildingBlocks/{JsonElementAssertionExtensions.cs => FluentJsonElementExtensions.cs} (99%) diff --git a/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs b/test/TestBuildingBlocks/FluentJsonElementExtensions.cs similarity index 99% rename from test/TestBuildingBlocks/JsonElementAssertionExtensions.cs rename to test/TestBuildingBlocks/FluentJsonElementExtensions.cs index 1526bcdade..76610ee881 100644 --- a/test/TestBuildingBlocks/JsonElementAssertionExtensions.cs +++ b/test/TestBuildingBlocks/FluentJsonElementExtensions.cs @@ -6,7 +6,7 @@ namespace TestBuildingBlocks; -public static class JsonElementAssertionExtensions +public static class FluentJsonElementExtensions { private const string ComponentSchemaPrefix = "#/components/schemas/";