Fluent Assertions extensions for ProblemDetails within HttpResponseMessage
You can install this NuGet package via .NET CLI:
dotnet add package FluentAssertions.ProblemDetail
HaveProblemDetails()
WithTitle()
WithStatusCode()
WithDetail()
WithDetailThatContains()
WithInstance()
WithExtensionsThatContain()
WithType()
using FluentAssertions;
using FluentAssertions.ProblemDetail.HttpResponse.Assertions;
...
// Given
User user = CreateUserWithInvalidEmailAddress();
// When
HttpResponseMessage response = await Client.PostAsJsonAsync("api/users", user);
// Then
response
.Should()
.HaveProblemDetails()
.WithTitle("Bad Request")
.WithStatusCode(StatusCodes.Status400BadRequest)
.WithDetail("User's email address is not valid!")
.WithInstance("/api/users")
.WithExtensionsThatContain("exceptionCode", "InvalidUserEmail")
.WithType("https://tools.ietf.org/html/rfc7231#section-6.5.1");