mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-17 23:14:23 +01:00
90 lines
2.3 KiB
Plaintext
90 lines
2.3 KiB
Plaintext
var server = WireMockServer.Start();
|
|
server
|
|
.Given(Request.Create()
|
|
.UsingMethod("GET")
|
|
.WithPath("/foo1")
|
|
.WithParam("p1", "xyz")
|
|
)
|
|
.WithGuid("90356dba-b36c-469a-a17e-669cd84f1f05")
|
|
.RespondWith(Response.Create()
|
|
.WithStatusCode(200)
|
|
.WithBody("1")
|
|
);
|
|
|
|
server
|
|
.Given(Request.Create()
|
|
.UsingMethod("POST")
|
|
.WithPath("/foo2")
|
|
.WithParam("p2", "abc")
|
|
.WithHeader("h1", "W/\"234f2q3r\"", true)
|
|
)
|
|
.WithGuid("1b731398-4a5b-457f-a6e3-d65e541c428f")
|
|
.RespondWith(Response.Create()
|
|
.WithStatusCode("201")
|
|
.WithHeader("hk", "hv")
|
|
.WithHeader("ETag", "W/\"168d8e\"")
|
|
.WithBody("2")
|
|
);
|
|
|
|
server
|
|
.Given(Request.Create()
|
|
.UsingMethod("DELETE")
|
|
.WithUrl("https://localhost/test")
|
|
)
|
|
.WithGuid("f74fd144-df53-404f-8e35-da22a640bd5f")
|
|
.RespondWith(Response.Create()
|
|
.WithStatusCode(208)
|
|
.WithBodyAsJson(new
|
|
{
|
|
@as = 1,
|
|
b = 1.2,
|
|
d = true,
|
|
e = false,
|
|
f = new [] { 1, 2, 3, 4 },
|
|
g = new
|
|
{
|
|
z1 = 1,
|
|
z2 = 2,
|
|
z3 = new [] { "a", "b", "c" },
|
|
z4 = new []
|
|
{
|
|
new
|
|
{
|
|
a = 1,
|
|
b = 2
|
|
},
|
|
new
|
|
{
|
|
a = 2,
|
|
b = 3
|
|
}
|
|
}
|
|
},
|
|
date_field = "2023-05-08T11:20:19",
|
|
string_field_with_date = "2021-03-13T21:04:00Z",
|
|
multiline_text = @"This
|
|
is
|
|
multiline
|
|
text
|
|
"
|
|
})
|
|
);
|
|
|
|
server
|
|
.Given(Request.Create()
|
|
.UsingMethod("POST")
|
|
.WithPath("/foo3")
|
|
.WithBody(new JsonPartialMatcher(
|
|
value: "{ a = 1, b = 2 }",
|
|
ignoreCase: false,
|
|
regex: false
|
|
))
|
|
)
|
|
.WithGuid("4126dec8-470b-4eff-93bb-c24f83b8b1fd")
|
|
.RespondWith(Response.Create()
|
|
.WithStatusCode(200)
|
|
.WithBody(@"Line1
|
|
Some ""value"" in Line2")
|
|
);
|
|
|