Skip to content

xiaoyvr/SimpleHttpMock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleHttpMock Build status

A really simple http mock using self host service.

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

About

A really simple http mock using self host service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published