Summary

Class:WireMock.Mapping
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Mapping.cs
Covered lines:36
Uncovered lines:0
Coverable lines:36
Total lines:105
Line coverage:100%
Branch coverage:92.8%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
GetRequestMatchResult(...)0011
.ctor(...)0010
ResponseToAsync()0011

File(s)

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

#LineLine coverage
 1using System;
 2using System.Threading.Tasks;
 3using JetBrains.Annotations;
 4using WireMock.Matchers.Request;
 5using WireMock.ResponseProviders;
 6
 7namespace WireMock
 8{
 9    /// <summary>
 10    /// The Mapping.
 11    /// </summary>
 12    public class Mapping : IMapping
 13    {
 14        /// <inheritdoc cref="IMapping.Guid" />
 54115        public Guid Guid { get; }
 16
 17        /// <inheritdoc cref="IMapping.Title" />
 4218        public string Title { get; }
 19
 20        /// <inheritdoc cref="IMapping.Path" />
 25021        public string Path { get; set; }
 22
 23        /// <inheritdoc cref="IMapping.Priority" />
 11824        public int Priority { get; }
 25
 26        /// <inheritdoc cref="IMapping.Scenario" />
 27        [CanBeNull]
 101628        public string Scenario { get; }
 29
 30        /// <inheritdoc cref="IMapping.ExecutionConditionState" />
 31        [CanBeNull]
 3732        public string ExecutionConditionState { get; }
 33
 34        /// <inheritdoc cref="IMapping.NextState" />
 35        [CanBeNull]
 2936        public string NextState { get; }
 37
 38        /// <inheritdoc cref="IMapping.RequestMatcher" />
 28439        public IRequestMatcher RequestMatcher { get; }
 40
 41        /// <inheritdoc cref="IMapping.Provider" />
 32342        public IResponseProvider Provider { get; }
 43
 44        /// <inheritdoc cref="IMapping.IsStartState" />
 945        public bool IsStartState => Scenario == null || Scenario != null && NextState != null && ExecutionConditionState
 46
 47        /// <inheritdoc cref="IMapping.IsAdminInterface" />
 11048        public bool IsAdminInterface => Provider is DynamicResponseProvider || Provider is DynamicAsyncResponseProvider 
 49
 50        /// <summary>
 51        /// Initializes a new instance of the <see cref="Mapping"/> class.
 52        /// </summary>
 53        /// <param name="guid">The unique identifier.</param>
 54        /// <param name="title">The unique title (can be null).</param>
 55        /// <param name="path">The full file path from this mapping title (can be null).</param>
 56        /// <param name="requestMatcher">The request matcher.</param>
 57        /// <param name="provider">The provider.</param>
 58        /// <param name="priority">The priority for this mapping.</param>
 59        /// <param name="scenario">The scenario. [Optional]</param>
 60        /// <param name="executionConditionState">State in which the current mapping can occur. [Optional]</param>
 61        /// <param name="nextState">The next state which will occur after the current mapping execution. [Optional]</par
 25062        public Mapping(Guid guid, [CanBeNull] string title, [CanBeNull] string path, IRequestMatcher requestMatcher, IRe
 25063        {
 25064            Guid = guid;
 25065            Title = title;
 25066            Path = path;
 25067            RequestMatcher = requestMatcher;
 25068            Provider = provider;
 25069            Priority = priority;
 25070            Scenario = scenario;
 25071            ExecutionConditionState = executionConditionState;
 25072            NextState = nextState;
 25073        }
 74
 75        /// <inheritdoc cref="IMapping.ResponseToAsync" />
 76        public async Task<ResponseMessage> ResponseToAsync(RequestMessage requestMessage)
 3577        {
 3578            return await Provider.ProvideResponseAsync(requestMessage);
 3579        }
 80
 81        /// <inheritdoc cref="IMapping.GetRequestMatchResult" />
 82        public RequestMatchResult GetRequestMatchResult(RequestMessage requestMessage, [CanBeNull] string nextState)
 27983        {
 27984            var result = new RequestMatchResult();
 85
 27986            RequestMatcher.GetMatchingScore(requestMessage, result);
 87
 88            // Only check state if Scenario is defined
 27989            if (Scenario != null)
 3090            {
 3091                var matcher = new RequestMessageScenarioAndStateMatcher(nextState, ExecutionConditionState);
 3092                matcher.GetMatchingScore(requestMessage, result);
 93                //// If ExecutionConditionState is null, this means that request is the start from a scenario. So just r
 94                //if (ExecutionConditionState != null)
 95                //{
 96                //    // ExecutionConditionState is not null, so get score for matching with the nextState.
 97                //    var matcher = new RequestMessageScenarioAndStateMatcher(nextState, ExecutionConditionState);
 98                //    matcher.GetMatchingScore(requestMessage, result);
 99                //}
 30100            }
 101
 279102            return result;
 279103        }
 104    }
 105}