WireMock.Net is a flexible library for stubbing and mocking web HTTP responses using requests matching criteria.
@darthkurak Your question looks a bit like this one: WireMock-Net/WireMock.Net#459
And if I understand you correct:
Correct?
Or else, create an issue at the GitHub project page and provide a full working example project.
@ntpincus You can use response templating using Handlebars.Net
https://github.com/WireMock-Net/WireMock.Net/wiki/Response-Templating
However, your example from summing up to parameters does not work because the values are interpreted as a string, and not as an int.
@ntpincus Actually it does work.
server
.Given(Request.Create().WithPath("/trans").UsingGet())
.WithGuid("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}}")
.WithHeader("xyz_{{request.headers.Postman-Token}}", "token is {{request.headers.Postman-Token}}")
.WithBody(@"{""msg"": ""Hello world CATCH-ALL on /*, {{request.path}}, add={{Math.Add request.query.start.[0] 42}} bykey={{request.query.start}}, bykey={{request.query.stop}}, byidx0={{request.query.stop.[0]}}, byidx1={{request.query.stop.[1]}}"" }")
.WithTransformer()
.WithDelay(TimeSpan.FromMilliseconds(100))
);
Call it with: http://localhost:9091/trans?start=1000&stop=1&stop=2
The arguments is an array of objects.
For Handlebars.Net, you need some workaround to get the real value: See https://github.com/StefH/Handlebars.Net.Helpers/blob/master/src/Handlebars.Net.Helpers/Parsers/ArgumentsParser.cs
myFolder/otherFolder
instead of __admin/mappings
is this possible through some configuration or do i have to implement a custom file handler?
@acanha This is currently only possible using a custom file handler.
See https://github.com/WireMock-Net/WireMock.Net/blob/395be3c5832bae26a187994c7913e6d200677ebd/examples/WireMock.Net.Console.Net452.Classic/CustomFileSystemFileHandler.cs#L7
However, adding this as a config-setting does also make sense. I'll take a look.
var s = await response.Content.ReadAsStringAsync();
var r = s.FromJson<IssueResponse>();
System.Net.Http.UnsupportedMediaTypeException : No MediaTypeFormatter is available to read an object of type 'IssueResponse' from content with media type 'aplication/json'
mobile app <=> backend
to mobile app <=> wiremock server
- but Im wondering if thats possible without changing the code of the app. I know that's possible with changing the codebase, from targeting my BE endpoints to target localhost (for iOS), but I'm wondering if thats doable somehow without changing the targeted endpoint in the codebase (for example with some proxy + wiremock settings). Unfortunately it's not possible to change the codebase, so I need to take it more like a blackbox. Any help? :) (also worth noting I'm running on a iOS simulator)