Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Provides a way to test WebAPI
C#
branch: master

README.md

WebAPI.Testing

Provides a way to test WebAPI projects.

public class GetDataTests
{
    [Fact]
    public void GetData_WhenRequested_ShouldReturnJSON()
    {
        var browser = new Browser();
        var response = browser.Get("/GetData", (with) =>
        {
            with.Header("Accept", "application/json");
            with.HttpRequest();
        });

        Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType);
    }

    [Fact]
    public void GetData_WhenRequested_ShouldReturnOKStatusCode()
    {
        var browser = new Browser();
        var response = browser.Get("/GetData", (with) =>
        {
            with.Header("Authorization", "Bearer johnsmith");
            with.Header("Accept", "application/json");
            with.HttpRequest();
        });

        Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
    }
}

This project is a modified version of Nancy.Testing but built to work with ASP.Net WebAPI

Something went wrong with that request. Please try again.