# WireMock.Server.RespondWithAProvider - Coverage Report

# Summary

Class: | WireMock.Server.RespondWithAProvider
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Server\RespondWithAProvider.cs
Covered lines: | 42
Uncovered lines: | 4
Coverable lines: | 46
Total lines: | 120
Line coverage: | 91.3%
Branch coverage: | 66.6%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
.ctor(...) | 1 | 0 | 100 | 100
RespondWith(...) | 2 | 2 | 100 | 100
WithGuid(...) | 1 | 0 | 100 | 100
WithGuid(...) | 1 | 0 | 100 | 100
WithTitle(...) | 1 | 0 | 100 | 100
WithPath(...) | 1 | 0 | 100 | 100
AtPriority(...) | 1 | 0 | 100 | 100
InScenario(...) | 1 | 0 | 100 | 100
WhenStateIs(...) | 2 | 2 | 71.43 | 66.67
WillSetStateTo(...) | 2 | 2 | 71.43 | 66.67

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Server\RespondWithAProvider.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using WireMock.Matchers.Request;`
|  | `3` |  | `using WireMock.ResponseProviders;`
|  | `4` |  | ``
|  | `5` |  | `namespace WireMock.Server`
|  | `6` |  | `{`
|  | `7` |  | `/// <summary>`
|  | `8` |  | `/// The respond with a provider.`
|  | `9` |  | `/// </summary>`
|  | `10` |  | `internal class RespondWithAProvider : IRespondWithAProvider`
|  | `11` |  | `{`
|  | `12` |  | `private int _priority;`
|  | `13` |  | `private Guid? _guid;`
|  | `14` |  | `private string _title;`
|  | `15` |  | `private string _path;`
|  | `16` |  | `private object _executionConditionState;`
|  | `17` |  | `private object _nextState;`
|  | `18` |  | `private string _scenario;`
|  | `19` |  | `private readonly RegistrationCallback _registrationCallback;`
|  | `20` |  | `private readonly IRequestMatcher _requestMatcher;`
|  | `21` |  | ``
|  | `22` |  | `/// <summary>`
|  | `23` |  | `/// Initializes a new instance of the <see cref="RespondWithAProvider"/> class.`
|  | `24` |  | `/// </summary>`
|  | `25` |  | `/// <param name="registrationCallback">The registration callback.</param>`
|  | `26` |  | `/// <param name="requestMatcher">The request matcher.</param>`
| 103 | `27` |  | `public RespondWithAProvider(RegistrationCallback registrationCallback, IRequestMatcher requestMatcher)`
| 103 | `28` |  | `{`
| 103 | `29` |  | `_registrationCallback = registrationCallback;`
| 103 | `30` |  | `_requestMatcher = requestMatcher;`
| 103 | `31` |  | `}`
|  | `32` |  | ``
|  | `33` |  | `/// <summary>`
|  | `34` |  | `/// The respond with.`
|  | `35` |  | `/// </summary>`
|  | `36` |  | `/// <param name="provider">The provider.</param>`
|  | `37` |  | `public void RespondWith(IResponseProvider provider)`
| 103 | `38` |  | `{`
| 103 | `39` |  | `var mappingGuid = _guid ?? Guid.NewGuid();`
| 103 | `40` |  | `_registrationCallback(new Mapping(mappingGuid, _title, _path, _requestMatcher, provider, _priority, _scenari`
| 103 | `41` |  | `}`
|  | `42` |  | ``
|  | `43` |  | `/// <see cref="IRespondWithAProvider.WithGuid(string)"/>`
|  | `44` |  | `public IRespondWithAProvider WithGuid(string guid)`
| 1 | `45` |  | `{`
| 1 | `46` |  | `return WithGuid(Guid.Parse(guid));`
| 1 | `47` |  | `}`
|  | `48` |  | ``
|  | `49` |  | `/// <see cref="IRespondWithAProvider.WithGuid(Guid)"/>`
|  | `50` |  | `public IRespondWithAProvider WithGuid(Guid guid)`
| 8 | `51` |  | `{`
| 8 | `52` |  | `_guid = guid;`
|  | `53` |  | ``
| 8 | `54` |  | `return this;`
| 8 | `55` |  | `}`
|  | `56` |  | ``
|  | `57` |  | `/// <see cref="IRespondWithAProvider.WithTitle"/>`
|  | `58` |  | `public IRespondWithAProvider WithTitle(string title)`
| 3 | `59` |  | `{`
| 3 | `60` |  | `_title = title;`
|  | `61` |  | ``
| 3 | `62` |  | `return this;`
| 3 | `63` |  | `}`
|  | `64` |  | ``
|  | `65` |  | `/// <see cref="IRespondWithAProvider.WithPath"/>`
|  | `66` |  | `public IRespondWithAProvider WithPath(string path)`
| 4 | `67` |  | `{`
| 4 | `68` |  | `_path = path;`
|  | `69` |  | ``
| 4 | `70` |  | `return this;`
| 4 | `71` |  | `}`
|  | `72` |  | ``
|  | `73` |  | `/// <see cref="IRespondWithAProvider.AtPriority"/>`
|  | `74` |  | `public IRespondWithAProvider AtPriority(int priority)`
| 7 | `75` |  | `{`
| 7 | `76` |  | `_priority = priority;`
|  | `77` |  | ``
| 7 | `78` |  | `return this;`
| 7 | `79` |  | `}`
|  | `80` |  | ``
|  | `81` |  | `/// <see cref="IRespondWithAProvider.InScenario(string)"/>`
|  | `82` |  | `public IRespondWithAProvider InScenario(string scenario)`
| 6 | `83` |  | `{`
| 6 | `84` |  | `_scenario = scenario;`
|  | `85` |  | ``
| 6 | `86` |  | `return this;`
| 6 | `87` |  | `}`
|  | `88` |  | ``
|  | `89` |  | `/// <see cref="IRespondWithAProvider.WhenStateIs"/>`
|  | `90` |  | `public IRespondWithAProvider WhenStateIs(object state)`
| 4 | `91` |  | `{`
| 4 | `92` |  | `if (string.IsNullOrEmpty(_scenario))`
| 0 | `93` |  | `{`
| 0 | `94` |  | `throw new NotSupportedException("Unable to set state condition when no scenario is defined.");`
|  | `95` |  | `}`
|  | `96` |  | ``
|  | `97` |  | `//if (_nextState != null)`
|  | `98` |  | `//{`
|  | `99` |  | `// throw new NotSupportedException("Unable to set state condition when next state is defined.");`
|  | `100` |  | `//}`
|  | `101` |  | ``
| 4 | `102` |  | `_executionConditionState = state;`
|  | `103` |  | ``
| 4 | `104` |  | `return this;`
| 4 | `105` |  | `}`
|  | `106` |  | ``
|  | `107` |  | `/// <see cref="IRespondWithAProvider.WillSetStateTo"/>`
|  | `108` |  | `public IRespondWithAProvider WillSetStateTo(object state)`
| 3 | `109` |  | `{`
| 3 | `110` |  | `if (string.IsNullOrEmpty(_scenario))`
| 0 | `111` |  | `{`
| 0 | `112` |  | `throw new NotSupportedException("Unable to set next state when no scenario is defined.");`
|  | `113` |  | `}`
|  | `114` |  | ``
| 3 | `115` |  | `_nextState = state;`
|  | `116` |  | ``
| 3 | `117` |  | `return this;`
| 3 | `118` |  | `}`
|  | `119` |  | `}`
|  | `120` |  | `}`

# Methods/Properties

.ctor(WireMock.RegistrationCallback,WireMock.Matchers.Request.IRequestMatcher)
RespondWith(WireMock.ResponseProviders.IResponseProvider)
WithGuid(System.String)
WithGuid(System.Guid)
WithTitle(System.String)
WithPath(System.String)
AtPriority(System.Int32)
InScenario(System.String)
WhenStateIs(System.Object)
WillSetStateTo(System.Object)