mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-25 17:58:33 +02:00
Implement Random Delay (#633)
* implement random delays * fixing CodeFactor issue * fix code comments * ... * UT Co-authored-by: Michael Yarichuk <michael.yarichuk@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using WireMock.Admin.Mappings;
|
||||
using WireMock.Matchers.Request;
|
||||
@@ -6,7 +7,6 @@ using WireMock.RequestBuilders;
|
||||
using WireMock.ResponseBuilders;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Types;
|
||||
using WireMock.Validation;
|
||||
|
||||
namespace WireMock.Serialization
|
||||
{
|
||||
@@ -16,9 +16,7 @@ namespace WireMock.Serialization
|
||||
|
||||
public MappingConverter(MatcherMapper mapper)
|
||||
{
|
||||
Check.NotNull(mapper, nameof(mapper));
|
||||
|
||||
_mapper = mapper;
|
||||
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
|
||||
}
|
||||
|
||||
public MappingModel ToMappingModel(IMapping mapping)
|
||||
@@ -81,12 +79,19 @@ namespace WireMock.Serialization
|
||||
Matchers = _mapper.Map(pm.Matchers)
|
||||
}).ToList() : null
|
||||
},
|
||||
Response = new ResponseModel
|
||||
{
|
||||
Delay = (int?)response.Delay?.TotalMilliseconds
|
||||
}
|
||||
Response = new ResponseModel()
|
||||
};
|
||||
|
||||
if (response.MinimumDelayMilliseconds >= 0 || response.MaximumDelayMilliseconds > 0)
|
||||
{
|
||||
mappingModel.Response.MinimumRandomDelay = response.MinimumDelayMilliseconds;
|
||||
mappingModel.Response.MaximumRandomDelay = response.MaximumDelayMilliseconds;
|
||||
}
|
||||
else
|
||||
{
|
||||
mappingModel.Response.Delay = (int?)response.Delay?.TotalMilliseconds;
|
||||
}
|
||||
|
||||
if (mapping.Webhooks?.Length == 1)
|
||||
{
|
||||
mappingModel.Webhook = WebhookMapper.Map(mapping.Webhooks[0]);
|
||||
|
||||
Reference in New Issue
Block a user