Add helpers for query params fluent MappingModelBuilder (#1425)

* Add helpers for query params

* add example with query params

* add fluent helpers for WithHeaders and WithCookies

---------

Co-authored-by: Logan Dam <Logan.Dam@rabobank.com>
Co-authored-by: Stef Heyenrath <Stef.Heyenrath@gmail.com>
This commit is contained in:
Logan Dam
2026-03-14 11:39:30 +02:00
committed by GitHub
parent c4caa25eb6
commit cdd33695e5
6 changed files with 178 additions and 0 deletions

View File

@@ -82,6 +82,51 @@ class Program
)
);
mappingBuilder.Given(m => m
.WithRequest(req => req
.WithPath("/testRequestWithQueryParams")
.UsingGet()
.WithParams(p => p.WithParam("param1", pb => pb.WithExactMatcher("value1")))
).WithResponse(rsp => rsp
.WithHeaders(h => h.Add("Content-Type", "application/json"))
.WithStatusCode(200)
.WithBodyAsJson(new
{
status = "ok"
}, true)
)
);
mappingBuilder.Given(m => m
.WithRequest(req => req
.WithPath("/testRequestWithHeaders")
.UsingGet()
.WithHeaders(h => h.WithHeader("Accept", hb => hb.WithExactMatcher("application/json")))
).WithResponse(rsp => rsp
.WithHeaders(h => h.Add("Content-Type", "application/json"))
.WithStatusCode(200)
.WithBodyAsJson(new
{
status = "ok"
}, true)
)
);
mappingBuilder.Given(m => m
.WithRequest(req => req
.WithPath("/testRequestWithCookie")
.UsingGet()
.WithCookies(c => c.WithCookie("cookie1", cb => cb.WithExactMatcher("cookievalue1")))
).WithResponse(rsp => rsp
.WithHeaders(h => h.Add("Content-Type", "application/json"))
.WithStatusCode(200)
.WithBodyAsJson(new
{
status = "ok"
}, true)
)
);
var result = await mappingBuilder.BuildAndPostAsync().ConfigureAwait(false);
Console.WriteLine($"result = {JsonConvert.SerializeObject(result)}");