From 2eff243a968e384251d0b6e9a417ceac07bc87d6 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Mon, 25 Jun 2018 19:36:41 +0200 Subject: [PATCH] Added JsonMatcher (#153) --- GitReleaseNotes.txt | 2 +- .../MainApp.cs | 16 +-- .../WireMock.Net.StandAlone.csproj | 2 +- .../Admin/Mappings/MatcherModel.cs | 5 + .../Matchers/ExactObjectMatcher.cs | 10 +- src/WireMock.Net/Matchers/IMatcher.cs | 1 - src/WireMock.Net/Matchers/IValueMatcher.cs | 15 +++ src/WireMock.Net/Matchers/JSONPathMatcher.cs | 5 +- src/WireMock.Net/Matchers/JsonMatcher.cs | 67 ++++++++++++ .../Serialization/MappingConverter.cs | 4 +- .../Serialization/MatcherMapper.cs | 58 +++++++++- .../Serialization/MatcherModelMapper.cs | 56 ---------- .../Server/FluentMockServer.Admin.cs | 13 ++- src/WireMock.Net/WireMock.Net.csproj | 2 +- .../Matchers/ExactObjectMatcherTests.cs | 8 +- .../Matchers/JsonMatcherTests.cs | 100 ++++++++++++++++++ .../Serialization/MatcherModelMapperTests.cs | 18 ++-- .../WireMock.Net.Tests.csproj | 8 +- 18 files changed, 288 insertions(+), 102 deletions(-) create mode 100644 src/WireMock.Net/Matchers/IValueMatcher.cs create mode 100644 src/WireMock.Net/Matchers/JsonMatcher.cs delete mode 100644 src/WireMock.Net/Serialization/MatcherModelMapper.cs create mode 100644 test/WireMock.Net.Tests/Matchers/JsonMatcherTests.cs diff --git a/GitReleaseNotes.txt b/GitReleaseNotes.txt index 9ceec828..4c12ea7e 100644 --- a/GitReleaseNotes.txt +++ b/GitReleaseNotes.txt @@ -1,5 +1,5 @@ https://github.com/GitTools/GitReleaseNotes -GitReleaseNotes.exe . /OutputFile CHANGELOG.md /Version 1.0.4.0 +GitReleaseNotes.exe . /OutputFile CHANGELOG.md /Version 1.0.4.1 GitReleaseNotes.exe . /OutputFile CHANGELOG.md /allTags diff --git a/examples/WireMock.Net.ConsoleApplication/MainApp.cs b/examples/WireMock.Net.ConsoleApplication/MainApp.cs index b9acbcd9..018ec483 100644 --- a/examples/WireMock.Net.ConsoleApplication/MainApp.cs +++ b/examples/WireMock.Net.ConsoleApplication/MainApp.cs @@ -38,12 +38,6 @@ namespace WireMock.Net.ConsoleApplication server.AllowPartialMapping(); - // .WithHeader("Stef", "Stef") - //server - // .Given(Request.Create().WithPath("*")) - // .RespondWith(Response.Create() - // .WithProxy("http://restcountries.eu")); - server .Given(Request .Create() @@ -53,6 +47,16 @@ namespace WireMock.Net.ConsoleApplication .RespondWith(Response.Create() .WithBody(@"{ ""result"": ""JsonPathMatcher !!!""}")); + server + .Given(Request + .Create() + .WithPath("/jsonbodytest") + .WithBody(new JsonMatcher("{ \"x\": 42, \"s\": \"s\" }")) + .UsingPost()) + .WithGuid("debaf408-3b23-4c04-9d18-ef1c020e79f2") + .RespondWith(Response.Create() + .WithBody(@"{ ""result"": ""jsonbodytest"" }")); + server .Given(Request .Create() diff --git a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj index 2ef36595..60a73401 100644 --- a/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj +++ b/src/WireMock.Net.StandAlone/WireMock.Net.StandAlone.csproj @@ -3,7 +3,7 @@ Lightweight StandAlone Http Mocking Server for .Net. WireMock.Net.StandAlone - 1.0.4.0 + 1.0.4.1 Stef Heyenrath net452;net46;netstandard1.3;netstandard2.0 true diff --git a/src/WireMock.Net/Admin/Mappings/MatcherModel.cs b/src/WireMock.Net/Admin/Mappings/MatcherModel.cs index 5033757e..3ffd23d6 100644 --- a/src/WireMock.Net/Admin/Mappings/MatcherModel.cs +++ b/src/WireMock.Net/Admin/Mappings/MatcherModel.cs @@ -10,6 +10,11 @@ /// public string Name { get; set; } + /// + /// Gets or sets the value. Used by . + /// + public string Value { get; set; } + /// /// Gets or sets the pattern. /// diff --git a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs index 3f8ebfb7..4f8847c7 100644 --- a/src/WireMock.Net/Matchers/ExactObjectMatcher.cs +++ b/src/WireMock.Net/Matchers/ExactObjectMatcher.cs @@ -5,7 +5,7 @@ using WireMock.Validation; namespace WireMock.Matchers { /// - /// ExactMatcher + /// ExactObjectMatcher /// /// public class ExactObjectMatcher : IObjectMatcher @@ -17,7 +17,7 @@ namespace WireMock.Matchers public MatchBehaviour MatchBehaviour { get; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The value. public ExactObjectMatcher([NotNull] object value) : this(MatchBehaviour.AcceptOnMatch, value) @@ -25,7 +25,7 @@ namespace WireMock.Matchers } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The match behaviour. /// The value. @@ -38,7 +38,7 @@ namespace WireMock.Matchers } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The value. public ExactObjectMatcher([NotNull] byte[] value) : this(MatchBehaviour.AcceptOnMatch, value) @@ -46,7 +46,7 @@ namespace WireMock.Matchers } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The match behaviour. /// The value. diff --git a/src/WireMock.Net/Matchers/IMatcher.cs b/src/WireMock.Net/Matchers/IMatcher.cs index 8aba538b..35650b4e 100644 --- a/src/WireMock.Net/Matchers/IMatcher.cs +++ b/src/WireMock.Net/Matchers/IMatcher.cs @@ -10,7 +10,6 @@ /// string Name { get; } - /// /// Gets the match behaviour. /// diff --git a/src/WireMock.Net/Matchers/IValueMatcher.cs b/src/WireMock.Net/Matchers/IValueMatcher.cs new file mode 100644 index 00000000..0d21ad12 --- /dev/null +++ b/src/WireMock.Net/Matchers/IValueMatcher.cs @@ -0,0 +1,15 @@ +namespace WireMock.Matchers +{ + /// + /// IValueMatcher + /// + /// + public interface IValueMatcher: IObjectMatcher + { + /// + /// Gets the value. + /// + /// Value + string GetValue(); + } +} \ No newline at end of file diff --git a/src/WireMock.Net/Matchers/JSONPathMatcher.cs b/src/WireMock.Net/Matchers/JSONPathMatcher.cs index 53ef6915..5a4a6241 100644 --- a/src/WireMock.Net/Matchers/JSONPathMatcher.cs +++ b/src/WireMock.Net/Matchers/JSONPathMatcher.cs @@ -10,6 +10,7 @@ namespace WireMock.Matchers /// JsonPathMatcher /// /// + /// public class JsonPathMatcher : IStringMatcher, IObjectMatcher { private readonly string[] _patterns; @@ -91,9 +92,9 @@ namespace WireMock.Matchers private double IsMatch(JToken jtoken) { // Wrap in array if needed - JToken jarray = jtoken is JArray ? jtoken : new JArray(jtoken); + JToken tokenOrArray = jtoken is JArray ? jtoken : new JArray(jtoken); - return MatchScores.ToScore(_patterns.Select(pattern => jarray.SelectToken(pattern) != null)); + return MatchScores.ToScore(_patterns.Select(pattern => tokenOrArray.SelectToken(pattern) != null)); } } } \ No newline at end of file diff --git a/src/WireMock.Net/Matchers/JsonMatcher.cs b/src/WireMock.Net/Matchers/JsonMatcher.cs new file mode 100644 index 00000000..5e6b734d --- /dev/null +++ b/src/WireMock.Net/Matchers/JsonMatcher.cs @@ -0,0 +1,67 @@ +using JetBrains.Annotations; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using WireMock.Validation; + +namespace WireMock.Matchers +{ + /// + /// JsonMatcher + /// + public class JsonMatcher : IValueMatcher + { + private readonly string _value; + + /// + public string Name => "JsonMatcher"; + + /// + public MatchBehaviour MatchBehaviour { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value to check for equality. + public JsonMatcher([NotNull] string value) : this(MatchBehaviour.AcceptOnMatch, value) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The match behaviour. + /// The value to check for equality. + public JsonMatcher(MatchBehaviour matchBehaviour, [NotNull] string value) + { + Check.NotNull(value, nameof(value)); + + MatchBehaviour = matchBehaviour; + _value = value; + } + + /// + public double IsMatch(object input) + { + bool match = false; + if (input != null) + { + try + { + // Check if JToken or object + JToken jtoken = input is JToken token ? token : JObject.FromObject(input); + + match = JToken.DeepEquals(JToken.Parse(_value), jtoken); + } + catch (JsonException) + { + // just ignore JsonException + } + } + + return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(match)); + } + + /// + public string GetValue() => _value; + } +} \ No newline at end of file diff --git a/src/WireMock.Net/Serialization/MappingConverter.cs b/src/WireMock.Net/Serialization/MappingConverter.cs index 8d0c1735..26c4b948 100644 --- a/src/WireMock.Net/Serialization/MappingConverter.cs +++ b/src/WireMock.Net/Serialization/MappingConverter.cs @@ -116,7 +116,7 @@ namespace WireMock.Serialization mappingModel.Response.BodyAsFileIsCached = response.ResponseMessage.BodyAsFileIsCached; mappingModel.Response.UseTransformer = response.UseTransformer; - if (response.ResponseMessage.BodyEncoding != null) + if (response.ResponseMessage.BodyEncoding != null && response.ResponseMessage.BodyEncoding.WebName != "utf-8") { mappingModel.Response.BodyEncoding = new EncodingModel { @@ -132,7 +132,7 @@ namespace WireMock.Serialization private static IDictionary Map(IDictionary> dictionary) { - if (dictionary == null) + if (dictionary == null || dictionary.Count == 0) { return null; } diff --git a/src/WireMock.Net/Serialization/MatcherMapper.cs b/src/WireMock.Net/Serialization/MatcherMapper.cs index b1f0f376..c7475ba8 100644 --- a/src/WireMock.Net/Serialization/MatcherMapper.cs +++ b/src/WireMock.Net/Serialization/MatcherMapper.cs @@ -1,6 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; +using SimMetrics.Net; using WireMock.Admin.Mappings; using WireMock.Matchers; @@ -8,6 +10,54 @@ namespace WireMock.Serialization { internal static class MatcherMapper { + public static IMatcher Map([CanBeNull] MatcherModel matcher) + { + if (matcher == null) + { + return null; + } + + string[] parts = matcher.Name.Split('.'); + string matcherName = parts[0]; + string matcherType = parts.Length > 1 ? parts[1] : null; + + string[] patterns = matcher.Patterns ?? new[] { matcher.Pattern }; + MatchBehaviour matchBehaviour = matcher.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch; + + switch (matcherName) + { + case "ExactMatcher": + return new ExactMatcher(matchBehaviour, patterns); + + case "RegexMatcher": + return new RegexMatcher(matchBehaviour, patterns, matcher.IgnoreCase == true); + + case "JsonMatcher": + return new JsonMatcher(matchBehaviour, matcher.Pattern); + + case "JsonPathMatcher": + return new JsonPathMatcher(matchBehaviour, patterns); + + case "XPathMatcher": + return new XPathMatcher(matchBehaviour, matcher.Pattern); + + case "WildcardMatcher": + return new WildcardMatcher(matchBehaviour, patterns, matcher.IgnoreCase == true); + + case "SimMetricsMatcher": + SimMetricType type = SimMetricType.Levenstein; + if (!string.IsNullOrEmpty(matcherType) && !Enum.TryParse(matcherType, out type)) + { + throw new NotSupportedException($"Matcher '{matcherName}' with Type '{matcherType}' is not supported."); + } + + return new SimMetricsMatcher(matchBehaviour, matcher.Pattern, type); + + default: + throw new NotSupportedException($"Matcher '{matcherName}' is not supported."); + } + } + public static MatcherModel[] Map([CanBeNull] IEnumerable matchers) { return matchers?.Select(Map).Where(x => x != null).ToArray(); @@ -20,9 +70,11 @@ namespace WireMock.Serialization return null; } - string[] patterns = matcher is IStringMatcher stringMatcher ? stringMatcher.GetPatterns() : new string[0]; + string[] patterns = matcher is IStringMatcher stringMatcher ? + stringMatcher.GetPatterns() : + matcher is IValueMatcher valueMatcher ? new[] { valueMatcher.GetValue() } : new string[0]; bool? ignorecase = matcher is IIgnoreCaseMatcher ignoreCaseMatcher ? ignoreCaseMatcher.IgnoreCase : (bool?)null; - bool? rejectOnMatch = matcher.MatchBehaviour == MatchBehaviour.RejectOnMatch ? true : (bool?) null; + bool? rejectOnMatch = matcher.MatchBehaviour == MatchBehaviour.RejectOnMatch ? true : (bool?)null; return new MatcherModel { diff --git a/src/WireMock.Net/Serialization/MatcherModelMapper.cs b/src/WireMock.Net/Serialization/MatcherModelMapper.cs deleted file mode 100644 index 91852d14..00000000 --- a/src/WireMock.Net/Serialization/MatcherModelMapper.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System; -using JetBrains.Annotations; -using SimMetrics.Net; -using WireMock.Admin.Mappings; -using WireMock.Matchers; - -namespace WireMock.Serialization -{ - internal static class MatcherModelMapper - { - public static IMatcher Map([CanBeNull] MatcherModel matcher) - { - if (matcher == null) - { - return null; - } - - string[] parts = matcher.Name.Split('.'); - string matcherName = parts[0]; - string matcherType = parts.Length > 1 ? parts[1] : null; - - string[] patterns = matcher.Patterns ?? new[] { matcher.Pattern }; - MatchBehaviour matchBehaviour = matcher.RejectOnMatch == true ? MatchBehaviour.RejectOnMatch : MatchBehaviour.AcceptOnMatch; - - switch (matcherName) - { - case "ExactMatcher": - return new ExactMatcher(matchBehaviour, patterns); - - case "RegexMatcher": - return new RegexMatcher(matchBehaviour, patterns, matcher.IgnoreCase == true); - - case "JsonPathMatcher": - return new JsonPathMatcher(matchBehaviour, patterns); - - case "XPathMatcher": - return new XPathMatcher(matchBehaviour, matcher.Pattern); - - case "WildcardMatcher": - return new WildcardMatcher(matchBehaviour, patterns, matcher.IgnoreCase == true); - - case "SimMetricsMatcher": - SimMetricType type = SimMetricType.Levenstein; - if (!string.IsNullOrEmpty(matcherType) && !Enum.TryParse(matcherType, out type)) - { - throw new NotSupportedException($"Matcher '{matcherName}' with Type '{matcherType}' is not supported."); - } - - return new SimMetricsMatcher(matchBehaviour, matcher.Pattern, type); - - default: - throw new NotSupportedException($"Matcher '{matcherName}' is not supported."); - } - } - } -} diff --git a/src/WireMock.Net/Server/FluentMockServer.Admin.cs b/src/WireMock.Net/Server/FluentMockServer.Admin.cs index 1038b0b8..1576b4d4 100644 --- a/src/WireMock.Net/Server/FluentMockServer.Admin.cs +++ b/src/WireMock.Net/Server/FluentMockServer.Admin.cs @@ -9,7 +9,6 @@ using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using WireMock.Admin.Mappings; -using WireMock.Admin.Requests; using WireMock.Admin.Settings; using WireMock.Http; using WireMock.Logging; @@ -549,7 +548,7 @@ namespace WireMock.Server var clientIPModel = JsonUtils.ParseJTokenToObject(requestModel.ClientIP); if (clientIPModel?.Matchers != null) { - requestBuilder = requestBuilder.WithPath(clientIPModel.Matchers.Select(MatcherModelMapper.Map).Cast().ToArray()); + requestBuilder = requestBuilder.WithPath(clientIPModel.Matchers.Select(MatcherMapper.Map).Cast().ToArray()); } } } @@ -565,7 +564,7 @@ namespace WireMock.Server var pathModel = JsonUtils.ParseJTokenToObject(requestModel.Path); if (pathModel?.Matchers != null) { - requestBuilder = requestBuilder.WithPath(pathModel.Matchers.Select(MatcherModelMapper.Map).Cast().ToArray()); + requestBuilder = requestBuilder.WithPath(pathModel.Matchers.Select(MatcherMapper.Map).Cast().ToArray()); } } } @@ -581,7 +580,7 @@ namespace WireMock.Server var urlModel = JsonUtils.ParseJTokenToObject(requestModel.Url); if (urlModel?.Matchers != null) { - requestBuilder = requestBuilder.WithUrl(urlModel.Matchers.Select(MatcherModelMapper.Map).Cast().ToArray()); + requestBuilder = requestBuilder.WithUrl(urlModel.Matchers.Select(MatcherMapper.Map).Cast().ToArray()); } } } @@ -595,7 +594,7 @@ namespace WireMock.Server { foreach (var headerModel in requestModel.Headers.Where(h => h.Matchers != null)) { - requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(MatcherModelMapper.Map).Cast().ToArray()); + requestBuilder = requestBuilder.WithHeader(headerModel.Name, headerModel.Matchers.Select(MatcherMapper.Map).Cast().ToArray()); } } @@ -603,7 +602,7 @@ namespace WireMock.Server { foreach (var cookieModel in requestModel.Cookies.Where(c => c.Matchers != null)) { - requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(MatcherModelMapper.Map).Cast().ToArray()); + requestBuilder = requestBuilder.WithCookie(cookieModel.Name, cookieModel.Matchers.Select(MatcherMapper.Map).Cast().ToArray()); } } @@ -617,7 +616,7 @@ namespace WireMock.Server if (requestModel.Body?.Matcher != null) { - var bodyMatcher = MatcherModelMapper.Map(requestModel.Body.Matcher); + var bodyMatcher = MatcherMapper.Map(requestModel.Body.Matcher); requestBuilder = requestBuilder.WithBody(bodyMatcher); } diff --git a/src/WireMock.Net/WireMock.Net.csproj b/src/WireMock.Net/WireMock.Net.csproj index 97dfeffd..637197c6 100644 --- a/src/WireMock.Net/WireMock.Net.csproj +++ b/src/WireMock.Net/WireMock.Net.csproj @@ -3,7 +3,7 @@ Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape. WireMock.Net - 1.0.4.0 + 1.0.4.1 Stef Heyenrath net452;net46;netstandard1.3;netstandard2.0 true diff --git a/test/WireMock.Net.Tests/Matchers/ExactObjectMatcherTests.cs b/test/WireMock.Net.Tests/Matchers/ExactObjectMatcherTests.cs index fa7cd6b4..fc1fec21 100644 --- a/test/WireMock.Net.Tests/Matchers/ExactObjectMatcherTests.cs +++ b/test/WireMock.Net.Tests/Matchers/ExactObjectMatcherTests.cs @@ -38,11 +38,11 @@ namespace WireMock.Net.Tests.Matchers public void ExactObjectMatcher_IsMatch_AcceptOnMatch() { // Assign - object obj = 1; + object obj = new { x = 500, s = "s" }; // Act var matcher = new ExactObjectMatcher(obj); - double result = matcher.IsMatch(1); + double result = matcher.IsMatch(new { x = 500, s = "s" }); // Assert Check.That(result).IsEqualTo(1.0); @@ -52,11 +52,11 @@ namespace WireMock.Net.Tests.Matchers public void ExactObjectMatcher_IsMatch_RejectOnMatch() { // Assign - object obj = 1; + object obj = new { x = 500, s = "s" }; // Act var matcher = new ExactObjectMatcher(MatchBehaviour.RejectOnMatch, obj); - double result = matcher.IsMatch(1); + double result = matcher.IsMatch(new { x = 500, s = "s" }); // Assert Check.That(result).IsEqualTo(0.0); diff --git a/test/WireMock.Net.Tests/Matchers/JsonMatcherTests.cs b/test/WireMock.Net.Tests/Matchers/JsonMatcherTests.cs new file mode 100644 index 00000000..978fdbb5 --- /dev/null +++ b/test/WireMock.Net.Tests/Matchers/JsonMatcherTests.cs @@ -0,0 +1,100 @@ +using Newtonsoft.Json.Linq; +using NFluent; +using WireMock.Matchers; +using Xunit; + +namespace WireMock.Net.Tests.Matchers +{ + public class JsonMatcherTests + { + [Fact] + public void JsonMatcher_GetName() + { + // Assign + var matcher = new JsonMatcher("{}"); + + // Act + string name = matcher.Name; + + // Assert + Check.That(name).Equals("JsonMatcher"); + } + + [Fact] + public void JsonMatcher_GetValue() + { + // Assign + var matcher = new JsonMatcher("{}"); + + // Act + string value = matcher.GetValue(); + + // Assert + Check.That(value).Equals("{}"); + } + + [Fact] + public void JsonMatcher_IsMatch_NullString() + { + // Assign + string s = null; + var matcher = new JsonMatcher(""); + + // Act + double match = matcher.IsMatch(s); + + // Assert + Check.That(match).IsEqualTo(0); + } + + [Fact] + public void JsonMatcher_IsMatch_NullObject() + { + // Assign + object o = null; + var matcher = new JsonMatcher(""); + + // Act + double match = matcher.IsMatch(o); + + // Assert + Check.That(match).IsEqualTo(0); + } + + [Fact] + public void JsonMatcher_IsMatch_JObject() + { + // Assign + var matcher = new JsonMatcher("{ \"Id\" : 1, \"Name\" : \"Test\" }"); + + // Act + var jobject = new JObject + { + { "Id", new JValue(1) }, + { "Name", new JValue("Test") } + }; + double match = matcher.IsMatch(jobject); + + // Assert + Assert.Equal(1.0, match); + } + + [Fact] + public void JsonMatcher_IsMatch_JObject_RejectOnMatch() + { + // Assign + var matcher = new JsonMatcher(MatchBehaviour.RejectOnMatch, "{ \"Id\" : 1, \"Name\" : \"Test\" }"); + + // Act + var jobject = new JObject + { + { "Id", new JValue(1) }, + { "Name", new JValue("Test") } + }; + double match = matcher.IsMatch(jobject); + + // Assert + Assert.Equal(0.0, match); + } + } +} \ No newline at end of file diff --git a/test/WireMock.Net.Tests/Serialization/MatcherModelMapperTests.cs b/test/WireMock.Net.Tests/Serialization/MatcherModelMapperTests.cs index 260fcaef..86a8a6a4 100644 --- a/test/WireMock.Net.Tests/Serialization/MatcherModelMapperTests.cs +++ b/test/WireMock.Net.Tests/Serialization/MatcherModelMapperTests.cs @@ -13,7 +13,7 @@ namespace WireMock.Net.Tests.Serialization public void MatcherModelMapper_Map_Null() { // Act - IMatcher matcher = MatcherModelMapper.Map(null); + IMatcher matcher = MatcherMapper.Map((MatcherModel)null); // Assert Check.That(matcher).IsNull(); @@ -30,7 +30,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (ExactMatcher)MatcherModelMapper.Map(model); + var matcher = (ExactMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x"); @@ -47,7 +47,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (ExactMatcher)MatcherModelMapper.Map(model); + var matcher = (ExactMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x", "y"); @@ -65,7 +65,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (RegexMatcher)MatcherModelMapper.Map(model); + var matcher = (RegexMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x", "y"); @@ -84,7 +84,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (WildcardMatcher)MatcherModelMapper.Map(model); + var matcher = (WildcardMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x", "y"); @@ -102,7 +102,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (SimMetricsMatcher)MatcherModelMapper.Map(model); + var matcher = (SimMetricsMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x"); @@ -119,7 +119,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - var matcher = (SimMetricsMatcher)MatcherModelMapper.Map(model); + var matcher = (SimMetricsMatcher)MatcherMapper.Map(model); // Assert Check.That(matcher.GetPatterns()).ContainsExactly("x"); @@ -136,7 +136,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - Check.ThatCode(() => MatcherModelMapper.Map(model)).Throws(); + Check.ThatCode(() => MatcherMapper.Map(model)).Throws(); } [Fact] @@ -150,7 +150,7 @@ namespace WireMock.Net.Tests.Serialization }; // Act - Check.ThatCode(() => MatcherModelMapper.Map(model)).Throws(); + Check.ThatCode(() => MatcherMapper.Map(model)).Throws(); } } } \ No newline at end of file diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj index df80645a..19d8667c 100644 --- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj +++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj @@ -14,17 +14,17 @@ - + - + - - + +