Partial matching

This commit is contained in:
Stef Heyenrath
2017-02-04 17:30:16 +01:00
parent 9b99a7f26b
commit ec2d105db2
19 changed files with 343 additions and 83 deletions

View File

@@ -18,6 +18,8 @@ namespace WireMock.Net.ConsoleApplication
var server = FluentMockServer.StartWithAdminInterface(url1, url2, url3);
Console.WriteLine("FluentMockServer listening at {0}", string.Join(" and ", server.Urls));
server.AllowPartialMapping();
server
.Given(Request.Create().WithPath(p => p.Contains("x")).UsingGet())
.AtPriority(4)
@@ -26,20 +28,6 @@ namespace WireMock.Net.ConsoleApplication
.WithHeader("Content-Type", "application/json")
.WithBody(@"{ ""result"": ""Contains x with FUNC 200""}"));
// http://localhost:8080/gffgfgf/sddsds?start=1000&stop=1&stop=2
server
.Given(Request.Create().WithPath("/*").UsingGet().WithParam("start"))
.WithGuid(Guid.Parse("90356dba-b36c-469a-a17e-669cd84f1f05"))
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
.WithHeader("Transformed-Postman-Token", "token is {{request.headers.Postman-Token}}")
.WithBody(@"{""msg"": ""Hello world, {{request.path}}, bykey={{request.query.start}}, bykey={{request.query.stop}}, byidx0={{request.query.stop.[0]}}, byidx1={{request.query.stop.[1]}}"" }")
.WithTransformer()
.WithDelay(1000)
.WithDelay(TimeSpan.FromMilliseconds(100))
);
server
.Given(Request.Create().WithPath("/data").UsingPost().WithBody(b => b.Contains("e")))
.RespondWith(Response.Create()
@@ -80,6 +68,24 @@ namespace WireMock.Net.ConsoleApplication
.RespondWith(Response.Create().WithDelay(TimeSpan.FromSeconds(1))
.WithStatusCode(200));
server
.Given(Request.Create().WithPath("/partial").UsingGet().WithHeader("p", "p"))
.RespondWith(Response.Create().WithStatusCode(200).WithBody("partial = 200"));
// http://localhost:8080/any/any?start=1000&stop=1&stop=2
server
.Given(Request.Create().WithPath("/*").UsingGet())
.WithGuid(Guid.Parse("90356dba-b36c-469a-a17e-669cd84f1f05"))
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
.WithHeader("Transformed-Postman-Token", "token is {{request.headers.Postman-Token}}")
.WithBody(@"{""msg"": ""Hello world CATCH-ALL on /*, {{request.path}}, bykey={{request.query.start}}, bykey={{request.query.stop}}, byidx0={{request.query.stop.[0]}}, byidx1={{request.query.stop.[1]}}"" }")
.WithTransformer()
.WithDelay(1000)
.WithDelay(TimeSpan.FromMilliseconds(100))
);
Console.WriteLine("Press any key to stop the server");
Console.ReadKey();