mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Query string match on DateTimeOffset is not working #211
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 @viktorpeacock on GitHub (Sep 19, 2019).
Hi,
I am sending two values via a query string and I am trying to configure wiremock to respond when these two values come through. First is an int and it works fine. Second is a DateTimeOffset in the following format:
"yyyy-MM-ddTHH\\:mm\\:ss.fffzzz"I have tried using the ExactValue matcher as so:
This does not work and the following is returned from the wiremock:
[Error] : HttpStatusCode set to 400 System.ArgumentException: values
at WireMock.Validation.Check.HasNoNulls[T](IList
1 value, String parameterName) at WireMock.Matchers.ExactMatcher..ctor(MatchBehaviour matchBehaviour, String[] values) at WireMock.Serialization.MatcherMapper.Map(MatcherModel matcher) at System.Linq.Enumerable.SelectArrayIterator2.MoveNext()at System.Linq.Enumerable.CastIterator[TResult](IEnumerable source)+MoveNext()
at System.Collections.Generic.LargeArrayBuilder
1.AddRange(IEnumerable1 items)at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable
1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)at WireMock.Server.FluentMockServer.InitRequestBuilder(RequestModel requestModel, Boolean pathOrUrlRequired)
at WireMock.Server.FluentMockServer.DeserializeAndAddOrUpdateMapping(MappingModel mappingModel, Nullable`1 guid, String path)
at WireMock.Server.FluentMockServer.MappingsPost(RequestMessage requestMessage)
However, when I use a standard dateTimeOffset.ToString(), then it works fine and the following is configured:
Is there any guidance/examples on how to work with datetime/datetimeoffset in a specific format? I thought it would treat it just like any other string.
@StefH commented on GitHub (Sep 19, 2019):
The issue is that when you post a mapping like this:
The string value
2019-09-19T18:02:31.7039950+02:00is actually converted to real DateTime, this means that some code fails.I'll investigate if this can be solved.
@viktorpeacock commented on GitHub (Sep 19, 2019):
Thank you. I was looking through code myself but it's difficult to get up to speed with it as I don't know how it all fits together. Maybe in future you could give a high level overview of the solution so that others can get up and running and contribute :-) thank you!
@StefH commented on GitHub (Sep 19, 2019):
I've made a fix.
Can you please try MyGet version : WireMock.Net.1.0.32-ci-11907
Can be tested with request like:
http://xxx/param2?dateTime=2019-09-19T18:02:31.7039950%2B02:00@viktorpeacock commented on GitHub (Sep 20, 2019):
Thank you for such a fast turnaround! Can you please update a Docker image as we use this in K8s to simulate our dependencies?
@StefH commented on GitHub (Sep 20, 2019):
I'll create a new official version tonight and also a new docker.
@StefH commented on GitHub (Sep 20, 2019):
@viktorpeacock : do double check : did you test it ?
@viktorpeacock commented on GitHub (Sep 20, 2019):
Hi Stef,
Yes. The following configuration and request worked for me:
Request: http://localhost:9092/test?dateTime=2019-09-20T11%3A03%3A17.221%2B00%3A00
Response:
{ "result": "2019-09-20T11:03:17.221+00:00}@StefH commented on GitHub (Sep 20, 2019):
I'll create a new official version tonight and also a new docker.
@viktorpeacock commented on GitHub (Sep 20, 2019):
You are a star! Thank you very much :-)