mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-21 16:48:59 +01:00
Add Func<> matchhing. Solves issue #2
This commit is contained in:
@@ -18,17 +18,26 @@ namespace WireMock.Net.ConsoleApplication
|
||||
Console.WriteLine("FluentMockServer running at {0}", server.Port);
|
||||
|
||||
server
|
||||
.Given(
|
||||
Request
|
||||
.WithUrl("/*")
|
||||
.UsingGet()
|
||||
)
|
||||
.RespondWith(
|
||||
Response
|
||||
.WithStatusCode(200)
|
||||
.WithHeader("Content-Type", "application/json")
|
||||
.WithBody(@"{ ""msg"": ""Hello world!""}")
|
||||
);
|
||||
.Given(Request.WithUrl(u => u.Contains("x")).UsingGet())
|
||||
.RespondWith(Response
|
||||
.WithStatusCode(200)
|
||||
.WithHeader("Content-Type", "application/json")
|
||||
.WithBody(@"{ ""result"": ""/x with FUNC 200""}"));
|
||||
|
||||
server
|
||||
.Given(Request.WithUrl("/*").UsingGet())
|
||||
.RespondWith(Response
|
||||
.WithStatusCode(200)
|
||||
.WithHeader("Content-Type", "application/json")
|
||||
.WithBody(@"{ ""msg"": ""Hello world!""}")
|
||||
);
|
||||
|
||||
server
|
||||
.Given(Request.WithUrl("/data").UsingPost().WithBody(b => b.Contains("e")))
|
||||
.RespondWith(Response
|
||||
.WithStatusCode(201)
|
||||
.WithHeader("Content-Type", "application/json")
|
||||
.WithBody(@"{ ""result"": ""data posted with FUNC 201""}"));
|
||||
|
||||
server
|
||||
.Given(Request.WithUrl("/data").UsingPost())
|
||||
@@ -42,12 +51,11 @@ namespace WireMock.Net.ConsoleApplication
|
||||
.RespondWith(Response
|
||||
.WithStatusCode(200)
|
||||
.WithHeader("Content-Type", "application/json")
|
||||
.WithBody(@"{ ""result"": ""data deleted with 201""}"));
|
||||
.WithBody(@"{ ""result"": ""data deleted with 200""}"));
|
||||
|
||||
Console.WriteLine("Press any key to stop the server");
|
||||
Console.ReadKey();
|
||||
|
||||
|
||||
Console.WriteLine("Displaying all requests");
|
||||
var allRequests = server.RequestLogs;
|
||||
Console.WriteLine(JsonConvert.SerializeObject(allRequests, Formatting.Indented));
|
||||
|
||||
Reference in New Issue
Block a user