Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 1.42 KB

File metadata and controls

39 lines (25 loc) · 1.42 KB

Build status

C# Tool for testing HTTP API with shapshots

This tool mocks responses from HTTP API. It's useful to make unit tests of your component, just stub the external APIs with a proxy server:

IFakeServer MyFakeServer = new FakeHttpServer("http://localhost:3000/");

Requests and Responses Settings

MyFakeServer.ShouldRecived().Post("request body").Response("response body");

The server replies once to a POST-request with the response "response body".

Incoming requests checks

MyFakeServer.CheckAllReciverConditional();

If the response has not been received then the exception would be raised using Assert.Fail("Some receiver conditionals are not met.") from Microsoft.VisualStudio.TestTools.UnitTesting.

To look at the actual incoming requests you can use GetReceiveHistory method:

string[] actualRequests = MyFakeServer.GetReceiveHistory();

Details

There're some useful options:

  • set HTTP headers (examples)
  • XML requests with the different object views and skipping some nodes` values (examples)
  • start a server on remote machine (examples)