Summary

Class:WireMock.Serialization.MatcherModelMapper
Assembly:WireMock.Net
File(s):C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Serialization\MatcherModelMapper.cs
Covered lines:19
Uncovered lines:2
Coverable lines:21
Total lines:55
Line coverage:90.4%
Branch coverage:86.3%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
Map(...)17204890.4886.96

File(s)

C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Serialization\MatcherModelMapper.cs

#LineLine coverage
 1using System;
 2using JetBrains.Annotations;
 3using SimMetrics.Net;
 4using WireMock.Admin.Mappings;
 5using WireMock.Matchers;
 6
 7namespace WireMock.Serialization
 8{
 9    internal static class MatcherModelMapper
 10    {
 11        public static IMatcher Map([CanBeNull] MatcherModel matcher)
 1512        {
 1513             if (matcher == null)
 114            {
 115                return null;
 16            }
 17
 1418            string[] parts = matcher.Name.Split('.');
 1419            string matcherName = parts[0];
 1420             string matcherType = parts.Length > 1 ? parts[1] : null;
 21
 1422            string[] patterns = matcher.Patterns ?? new[] { matcher.Pattern };
 23
 1424             switch (matcherName)
 25            {
 26                case "ExactMatcher":
 627                    return new ExactMatcher(patterns);
 28
 29                case "RegexMatcher":
 130                     return new RegexMatcher(patterns, matcher.IgnoreCase == true);
 31
 32                case "JsonPathMatcher":
 033                    return new JsonPathMatcher(patterns);
 34
 35                case "XPathMatcher":
 036                    return new XPathMatcher(matcher.Pattern);
 37
 38                case "WildcardMatcher":
 339                     return new WildcardMatcher(patterns, matcher.IgnoreCase == true);
 40
 41                case "SimMetricsMatcher":
 342                    SimMetricType type = SimMetricType.Levenstein;
 343                     if (!string.IsNullOrEmpty(matcherType) && !Enum.TryParse(matcherType, out type))
 144                    {
 145                        throw new NotSupportedException($"Matcher '{matcherName}' with Type '{matcherType}' is not suppo
 46                    }
 47
 248                    return new SimMetricsMatcher(matcher.Pattern, type);
 49
 50                default:
 151                    throw new NotSupportedException($"Matcher '{matcherName}' is not supported.");
 52            }
 1353        }
 54    }
 55}