Summary

Class:WireMock.Server.RespondWithAProvider
Assembly:WireMock.Net
File(s):C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\RespondWithAProvider.cs
Covered lines:21
Uncovered lines:3
Coverable lines:24
Total lines:94
Line coverage:87.5%
Branch coverage:100%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor(...)10100100
RespondWith(...)22100100
WithGuid(...)1000
WithGuid(...)10100100
WithTitle(...)10100100
AtPriority(...)10100100

File(s)

C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Server\RespondWithAProvider.cs

#LineLine coverage
 1using System;
 2using WireMock.Matchers.Request;
 3
 4namespace WireMock.Server
 5{
 6    /// <summary>
 7    /// The respond with a provider.
 8    /// </summary>
 9    internal class RespondWithAProvider : IRespondWithAProvider
 10    {
 11        private int _priority;
 12        private Guid? _guid;
 13        private string _title;
 14
 15        /// <summary>
 16        /// The _registration callback.
 17        /// </summary>
 18        private readonly RegistrationCallback _registrationCallback;
 19
 20        /// <summary>
 21        /// The _request matcher.
 22        /// </summary>
 23        private readonly IRequestMatcher _requestMatcher;
 24
 25        /// <summary>
 26        /// Initializes a new instance of the <see cref="RespondWithAProvider"/> class.
 27        /// </summary>
 28        /// <param name="registrationCallback">The registration callback.</param>
 29        /// <param name="requestMatcher">The request matcher.</param>
 1730        public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher)
 1731        {
 1732            _registrationCallback = registrationCallback;
 1733            _requestMatcher = requestMatcher;
 1734        }
 35
 36        /// <summary>
 37        /// The respond with.
 38        /// </summary>
 39        /// <param name="provider">
 40        /// The provider.
 41        /// </param>
 42        public void RespondWith(IResponseProvider provider)
 1743        {
 1744             var mappingGuid = _guid ?? Guid.NewGuid();
 1745            _registrationCallback(new Mapping(mappingGuid, _title, _requestMatcher, provider, _priority));
 1746        }
 47
 48        /// <summary>
 49        /// Define a unique identifier for this mapping.
 50        /// </summary>
 51        /// <param name="guid">The unique identifier.</param>
 52        /// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
 53        public IRespondWithAProvider WithGuid(string guid)
 054        {
 055            return WithGuid(Guid.Parse(guid));
 056        }
 57
 58        /// <summary>
 59        /// Define a unique identifier for this mapping.
 60        /// </summary>
 61        /// <param name="guid">The unique identifier.</param>
 62        /// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
 63        public IRespondWithAProvider WithGuid(Guid guid)
 764        {
 765            _guid = guid;
 66
 767            return this;
 768        }
 69
 70        /// <summary>
 71        /// Define a unique identifier for this mapping.
 72        /// </summary>
 73        /// <param name="title">The unique identifier.</param>
 74        /// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
 75        public IRespondWithAProvider WithTitle(string title)
 276        {
 277            _title = title;
 78
 279            return this;
 280        }
 81
 82        /// <summary>
 83        /// Define the priority for this mapping.
 84        /// </summary>
 85        /// <param name="priority">The priority.</param>
 86        /// <returns>The <see cref="IRespondWithAProvider"/>.</returns>
 87        public IRespondWithAProvider AtPriority(int priority)
 688        {
 689            _priority = priority;
 90
 691            return this;
 692        }
 93    }
 94}