Summary

Class:WireMock.Owin.MappingMatcher
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Owin\MappingMatcher.cs
Covered lines:27
Uncovered lines:0
Coverable lines:27
Total lines:48
Line coverage:100%
Branch coverage:90.9%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
Match(...)0010.909
.ctor(...)0010

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Owin\MappingMatcher.cs

#LineLine coverage
 1using System.Linq;
 2using WireMock.Matchers.Request;
 3using WireMock.Validation;
 4
 5namespace WireMock.Owin
 6{
 7    internal class MappingMatcher : IMappingMatcher
 8    {
 9        private readonly IWireMockMiddlewareOptions _options;
 10
 5011        public MappingMatcher(IWireMockMiddlewareOptions options)
 5012        {
 5013            Check.NotNull(options, nameof(options));
 14
 5015            _options = options;
 5016        }
 17
 18        public (IMapping Mapping, RequestMatchResult RequestMatchResult) Match(RequestMessage request)
 4919        {
 4920            var mappings = _options.Mappings.Values
 33221                .Select(m => new
 33222                {
 33223                    Mapping = m,
 33224                    MatchResult = m.GetRequestMatchResult(request, m.Scenario != null && _options.Scenarios.ContainsKey(
 33225                })
 4926                .ToList();
 27
 4928            if (_options.AllowPartialMapping)
 129            {
 130                var partialMappings = mappings
 331                    .Where(pm => (pm.Mapping.IsAdminInterface && pm.MatchResult.IsPerfectMatch) || !pm.Mapping.IsAdminIn
 332                    .OrderBy(m => m.MatchResult)
 333                    .ThenBy(m => m.Mapping.Priority)
 134                    .ToList();
 35
 236                var bestPartialMatch = partialMappings.FirstOrDefault(pm => pm.MatchResult.AverageTotalScore > 0.0);
 37
 138                return (bestPartialMatch?.Mapping, bestPartialMatch?.MatchResult);
 39            }
 40
 4841            var perfectMatch = mappings
 8542                .OrderBy(m => m.Mapping.Priority)
 32943                .FirstOrDefault(m => m.MatchResult.IsPerfectMatch);
 44
 4845            return (perfectMatch?.Mapping, perfectMatch?.MatchResult);
 4946        }
 47    }
 48}