stateful behavior + tests

This commit is contained in:
deeptowncitizen
2017-10-04 15:57:49 -04:00
parent 8827531391
commit ab017beaa6
8 changed files with 193 additions and 3 deletions

View File

@@ -24,15 +24,19 @@ namespace WireMock.Owin
private readonly OwinRequestMapper _requestMapper = new OwinRequestMapper();
private readonly OwinResponseMapper _responseMapper = new OwinResponseMapper();
public object State { get; private set; }
#if !NETSTANDARD
public WireMockMiddleware(OwinMiddleware next, WireMockMiddlewareOptions options) : base(next)
{
_options = options;
State = null;
}
#else
public WireMockMiddleware(RequestDelegate next, WireMockMiddlewareOptions options)
{
_options = options;
State = null;
}
#endif
@@ -51,6 +55,7 @@ namespace WireMock.Owin
try
{
var mappings = _options.Mappings
.Where(m => object.Equals(m.ExecutionConditionState, State))
.Select(m => new
{
Mapping = m,
@@ -107,6 +112,7 @@ namespace WireMock.Owin
}
response = await targetMapping.ResponseToAsync(request);
State = targetMapping.NextState;
}
catch (Exception ex)
{