mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-29 20:27:27 +02:00
Fix partialMappings
This commit is contained in:
@@ -29,6 +29,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Tests", "test\
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone", "src\WireMock.Net.StandAlone\WireMock.Net.StandAlone.csproj", "{668F689E-57B4-422E-8846-C0FF643CA999}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{D3804228-91F4-4502-9595-39584E5A01AD} = {D3804228-91F4-4502-9595-39584E5A01AD}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -335,13 +335,13 @@ namespace WireMock.Server
|
||||
RequestMatchResult requestMatchResult = null;
|
||||
try
|
||||
{
|
||||
var possibleMatchingMappings = _mappings
|
||||
var mappings = _mappings
|
||||
.Select(m => new { Mapping = m, MatchResult = m.IsRequestHandled(request) })
|
||||
.ToList();
|
||||
|
||||
if (_allowPartialMapping)
|
||||
{
|
||||
var orderedMappings = possibleMatchingMappings
|
||||
var partialMappings = mappings
|
||||
.Where(pm =>
|
||||
(pm.Mapping.Provider is DynamicResponseProvider && pm.MatchResult.IsPerfectMatch) ||
|
||||
!(pm.Mapping.Provider is DynamicResponseProvider)
|
||||
@@ -350,14 +350,14 @@ namespace WireMock.Server
|
||||
.ThenBy(m => m.Mapping.Priority)
|
||||
.ToList();
|
||||
|
||||
var bestPartialMatch = orderedMappings.FirstOrDefault();
|
||||
var bestPartialMatch = partialMappings.FirstOrDefault(pm => pm.MatchResult.MatchPercentage > 0.0);
|
||||
|
||||
targetMapping = bestPartialMatch?.Mapping;
|
||||
requestMatchResult = bestPartialMatch?.MatchResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
var perfectMatch = possibleMatchingMappings
|
||||
var perfectMatch = mappings
|
||||
.OrderBy(m => m.Mapping.Priority)
|
||||
.FirstOrDefault(m => m.MatchResult.IsPerfectMatch);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user