WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
I tried this implementation: "{{Random Type=\"Long\" Min=1000000000 Max=9999999999}}", but I am getting an error, even though 1000000000 and 9999999999 are valid Int64 numbers.
Is this handlebar expression correct? Or do we have a bug when generating Random long numbers?
Following are more details.
Implementation
var settings = new WireMockServerSettings
{
AllowPartialMapping = true,
StartAdminInterface = true,
Urls = new[] { "http://localhost:3000/", },
Logger = new WireMockConsoleLogger(),
};
var server = StandAloneApp.Start(settings);
server
.Given(Request.Create()
.WithPath(new ExactMatcher("/"))
.UsingGet())
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
.WithBodyAsJson(new
{
id = "{{Random Type=\"Long\" Min=1000000000 Max=9999999999}}",
})
.WithTransformer());
Console.WriteLine("Press any key to stop the server");
Console.ReadKey();
Response (error)
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Date: Fri, 08 Dec 2023 16:36:45 GMT
Server: Kestrel
Transfer-Encoding: chunked
{"Status":"Object of type 'System.String' cannot be converted to type 'System.Int64'."}
How to get a Random Long?
I tried this implementation:
"{{Random Type=\"Long\" Min=1000000000 Max=9999999999}}"
, but I am getting an error, even though1000000000
and9999999999
are valid Int64 numbers.Is this handlebar expression correct? Or do we have a bug when generating Random
long
numbers?Following are more details.
Implementation
Response (error)
Logs
Please, let me know if you need any other information. Thanks.