mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
ExactMatcher does not accept ISO8601 DateTime? #230
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jglavic on GitHub (Dec 2, 2019).
Hi, I am trying to respond to the following sample request:
[GET] http://localhost/api/update?since=2019-12-01T22:10:25.000Z
using this mapping in a json file:
I am receiving a 404 response.
The mapping does not even get registered. The otuput log says:
Have you got any ideas why this won't work as expected??
thank you! (ps: great project I love it!)
@StefH commented on GitHub (Dec 2, 2019):
The error message
REST\mappings\update_1.jsonis a different one, not related to ExactMatcher.When I post your mapping and test it using a GET, it works fine:

@StefH commented on GitHub (Dec 3, 2019):
@yankeepenky Do you still need support on this issue?
@jglavic commented on GitHub (Dec 4, 2019):
sorry for my late reply!
first, the strange issue occured when using
"Matchers": [ {"Name": "...", "Pattern": "..."}]. As soon as I changed that to "Patterns": [ "..." ] the file was read in successfully.Now the _value of the matcher was still empty...

Next I changed from VS2015 to VS2017 in order to check the issue there. I now receive the following exception when trying to call any path with any http method:
Environment: VS2017, targeting .NET 4.7.2 (full framework)
As soon as I fixed that issue (which does not seem to be connected to wiremock) I'll report back.
@StefH commented on GitHub (Dec 5, 2019):
Just using
Patternshould also work fine.@jglavic commented on GitHub (Dec 13, 2019):
@StefH I checked the issue again, now while debugging your code:
This is the json file:
"Request": { "Path": { "Matchers": [ { "Name": "ExactMatcher", "Pattern": "/api/update" } ] }, "Params": [ { "Name": "since", "Matchers": [ { "Name": "ExactMatcher", "Pattern": "2019-12-01T22:10:25.000Z" } ] } ], "Methods": [ "get" ] },The issue is the pattern being cast to a DateTime:
Serialization\MatcherMapper.cs line 39:
string[] stringPatterns = matcher.Patterns != null ? matcher.Patterns.OfType<string>().ToArray() : new[] { matcher.Pattern as string };here matcher.Pattern is a DateTime and
matcher.Pattern as stringreturns null.Serialization occurs here: Server\FluentMockServer.Admin.cs Line 232
var mappingModels = DeserializeObjectToArray<MappingModel>(JsonConvert.DeserializeObject(value));@StefH commented on GitHub (Dec 13, 2019):
@yankeepenky I understand your issue.
I fixed it, can you try version
WireMock.Net.1.0.40-ci-12334from MyGet?@jglavic commented on GitHub (Dec 14, 2019):
@StefH Great news! all my tests succeeded! thank you for your fix...
I am waiting now for the next release - this issue was solved.