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