mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-20 00:25:06 +01:00
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
|
||||
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
|
||||
<Version>1.0.3.1</Version>
|
||||
<Version>1.0.3.2</Version>
|
||||
<Authors>Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net452;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace WireMock.Owin
|
||||
RequestMatchResult requestMatchResult = null;
|
||||
try
|
||||
{
|
||||
foreach (var mapping in _options.Mappings.Where(m => m?.Scenario != null))
|
||||
foreach (var mapping in _options.Mappings.Values.Where(m => m?.Scenario != null))
|
||||
{
|
||||
// Set start
|
||||
if (!_options.Scenarios.ContainsKey(mapping.Scenario) && mapping.IsStartState)
|
||||
@@ -64,7 +64,7 @@ namespace WireMock.Owin
|
||||
}
|
||||
}
|
||||
|
||||
var mappings = _options.Mappings
|
||||
var mappings = _options.Mappings.Values
|
||||
.Select(m => new
|
||||
{
|
||||
Mapping = m,
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace WireMock.Owin
|
||||
|
||||
public bool AllowPartialMapping { get; set; }
|
||||
|
||||
public IList<Mapping> Mappings { get; set; } = new List<Mapping>();
|
||||
public IDictionary<Guid, Mapping> Mappings { get; set; } = new ConcurrentDictionary<Guid, Mapping>();
|
||||
|
||||
public ObservableCollection<LogEntry> LogEntries { get; } = new ConcurentObservableCollection<LogEntry>();
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace WireMock.Server
|
||||
if (settings.SaveMapping)
|
||||
{
|
||||
var mapping = ToMapping(requestMessage, responseMessage, settings.BlackListedHeaders ?? new string[] { });
|
||||
_options.Mappings.Add(mapping);
|
||||
_options.Mappings.Add(mapping.Guid, mapping);
|
||||
|
||||
if (settings.SaveMappingToFile)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace WireMock.Server
|
||||
/// Gets the mappings.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public IEnumerable<Mapping> Mappings => new ReadOnlyCollection<Mapping>(_options.Mappings);
|
||||
public IEnumerable<Mapping> Mappings => _options.Mappings.Values.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scenarios.
|
||||
@@ -273,7 +273,10 @@ namespace WireMock.Server
|
||||
[PublicAPI]
|
||||
public void ResetMappings()
|
||||
{
|
||||
_options.Mappings = _options.Mappings.Where(m => m.IsAdminInterface).ToList();
|
||||
foreach (var nonAdmin in _options.Mappings.Where(m => !m.Value.IsAdminInterface))
|
||||
{
|
||||
_options.Mappings.Remove(nonAdmin);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -284,25 +287,19 @@ namespace WireMock.Server
|
||||
public bool DeleteMapping(Guid guid)
|
||||
{
|
||||
// Check a mapping exists with the same GUID, if so, remove it.
|
||||
return DeleteMapping(m => m.Guid == guid);
|
||||
if (_options.Mappings.ContainsKey(guid))
|
||||
{
|
||||
return _options.Mappings.Remove(guid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool DeleteMapping(string path)
|
||||
{
|
||||
// Check a mapping exists with the same path, if so, remove it.
|
||||
return DeleteMapping(m => string.Equals(m.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private bool DeleteMapping(Func<Mapping, bool> predicate)
|
||||
{
|
||||
var existingMapping = _options.Mappings.FirstOrDefault(predicate);
|
||||
if (existingMapping != null)
|
||||
{
|
||||
_options.Mappings.Remove(existingMapping);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
var mapping = _options.Mappings.FirstOrDefault(entry => string.Equals(entry.Value.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
return DeleteMapping(mapping.Key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -393,14 +390,13 @@ namespace WireMock.Server
|
||||
private void RegisterMapping(Mapping mapping)
|
||||
{
|
||||
// Check a mapping exists with the same Guid, if so, replace it.
|
||||
var existingMapping = _options.Mappings.FirstOrDefault(m => m.Guid == mapping.Guid);
|
||||
if (existingMapping != null)
|
||||
if (_options.Mappings.ContainsKey(mapping.Guid))
|
||||
{
|
||||
_options.Mappings[_options.Mappings.IndexOf(existingMapping)] = mapping;
|
||||
_options.Mappings[mapping.Guid] = mapping;
|
||||
}
|
||||
else
|
||||
{
|
||||
_options.Mappings.Add(mapping);
|
||||
_options.Mappings.Add(mapping.Guid, mapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Description>Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.</Description>
|
||||
<AssemblyTitle>WireMock.Net</AssemblyTitle>
|
||||
<Version>1.0.3.1</Version>
|
||||
<Version>1.0.3.2</Version>
|
||||
<Authors>Alexandre Victoor;Stef Heyenrath</Authors>
|
||||
<TargetFrameworks>net452;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
|
||||
Reference in New Issue
Block a user