Closed hmiguel closed 3 months ago
I am not sure if I can follow correctly, but if you are intending to have a builder for the admin-interface, this has been added by the link you posted, and there is no extension code (the one that I proposed) needed, as it's now working out of the box.
What is your exact issue, as your code seems to be just fine?
from what I can see the only difference here is that the example code has
var result = await mappingBuilder.BuildAndPostAsync().ConfigureAwait(false);
Cheers.
My issue is that you don't have an api.MappingBuilder()
, only a api.GetMappingBuilder()
;
And then, api.GetMappingBuilder()
doesn't have the same syntax, neither access to WithBody(IMatcher matcher)
, i.e..
Best
For an example on the mapping builder: see https://github.com/WireMock-Net/WireMock.Net/blob/master/examples/WireMock.Net.Client/Program.cs#L22
@StefH I can't see any example with body using matchers, only strings, i.e. .WithBody(new JmesPathMatcher("things.name == 'RequiredThing'")))
.
Correct, the JmesPathMatcher (from the server project) is not available if you use the client builder.
If you only have use client-side, you need code like this:
mappingBuilder.Given(m => m
.WithRequest(req => req
.WithPath("/test1")
.UsingPost()
.WithBody(b => b
.WithMatcher(match => match
.WithName("JmesPathMatcher")
.WithPattern("things.name == 'RequiredThing'")
)
)
)
.WithResponse(rsp => rsp
.WithHeaders(h => h.Add("Content-Type", "application/json"))
.WithDelay(TimeSpan.FromMilliseconds(50))
.WithStatusCode(200)
.WithBodyAsJson(new
{
status = "ok"
}, true)
)
);
If so, I prefer to use @R0boC0p extension. Thanks
As stated by @R0boC0p, that extension is not available. The only code which is available on the client is the code I posted.
Hello,
I'm trying to replicate the following server mapping using wiremock.net rest client.
Right now, I successfully made it using @R0boC0p extension from here. It look like this:
My question is: is there any built-in way to do it?