Skip to content

Fluent Assertions extensions for ProblemDetails within HttpResponseMessage

License

Notifications You must be signed in to change notification settings

farazazadi/FluentAssertions.ProblemDetail

Repository files navigation

CI Release

FluentAssertions.ProblemDetail

Fluent Assertions extensions for ProblemDetails within HttpResponseMessage

Installation

You can install this NuGet package via .NET CLI:

dotnet add package FluentAssertions.ProblemDetail 

Available extension methods

  • HaveProblemDetails()
  • WithTitle()
  • WithStatusCode()
  • WithDetail()
  • WithDetailThatContains()
  • WithInstance()
  • WithExtensionsThatContain()
  • WithType()

Usage

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");

About

Fluent Assertions extensions for ProblemDetails within HttpResponseMessage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages