Skip to content

Instantly share code, notes, and snippets.

@hibri
Created June 5, 2011 11:40
Show Gist options
  • Save hibri/1008889 to your computer and use it in GitHub Desktop.
Save hibri/1008889 to your computer and use it in GitHub Desktop.
Http Mocking
[Test]
public void Foo() {
IHttpEndpoint httpEndpoint = new HttpEndpoint()
.At(new Uri("Http://localhost:8080/api"))
.WithNewContext();
httpEndpoint
.Stub(x => x.Get("/"))
.Return("Index")
.OK();
httpEndpoint
.Stub(x => x.Get("/status"))
.Return("Hello")
.OK();
httpEndpoint
.Stub(x => x.Get("/echo"))
.Return("Echo")
.OK();
WebClient wc = new WebClient();
Console.WriteLine(wc.DownloadString("Http://localhost:8080/api/"));
Console.WriteLine(wc.DownloadString("Http://localhost:8080/api/status"));
Console.WriteLine(wc.DownloadString("Http://localhost:8080/api/echo"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment