A really simple http mock using self host service.
- 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);
serverBuilder
.When(Matchers.Wildcard(@"/staffs/?"), HttpMethod.Patch)
.Respond(HttpStatusCode.Unauthorized);