A really simple http mock using self host service.
C# Batchfile
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 7 commits ahead, 1 commit behind Suremaker:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.nuget
src/SimpleHttpMock
test/unit-test
.gitignore
LICENSE
README.md
package.bat
simple-http-mock.sln

README.md

SimpleHttpMock (Wonga fork of xiaoyvr/SimpleHttpMock)

A really simple http mock using self host service.

Differences in comparison to the original project

  • added ability to reconfigure server on runtime with MockedHttpServerBuilder.Reconfigure() method
  • fixed RequestBehaviorBuilder.RespondContent() method

Using Hamcrest Matchers

  • Matchers.Regex
 var serverBuilder = new MockedHttpServerBuilder();
 serverBuilder
     .WhenGet(Matchers.Regex(@"/(staff)|(user)s"))
     .Respond(HttpStatusCode.InternalServerError);

 using (serverBuilder.Build(BaseAddress))
 {
     var response = Get("http://localhost/users"));
     Assert.Equal(HttpStatusCode.InternalServerError, response.StatusCode);
 }
  • Matchers.WildCard
serverBuilder
    .WhenGet(Matchers.Wildcard(@"/staffs/?"))
    .Respond(HttpStatusCode.Unauthorized);
  • Matchers.Is
serverBuilder
     .WhenGet(Matchers.Is("/staffs"))
     .Respond(HttpStatusCode.OK);

Other methods

serverBuilder
    .When(Matchers.Wildcard(@"/staffs/?"), HttpMethod.Patch)
    .Respond(HttpStatusCode.Unauthorized);