-
-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace WireMock.Matchers.Request | ||
{ | ||
public class MatchDetail | ||
{ | ||
public Type MatcherType { get; set; } | ||
|
||
public double Score { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
test/WireMock.Net.Tests/Matchers/RequestMatchResultTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Linq; | ||
using FluentAssertions; | ||
using WireMock.Matchers; | ||
using WireMock.Matchers.Request; | ||
using Xunit; | ||
|
||
namespace WireMock.Net.Tests.Matchers | ||
{ | ||
public class RequestMatchResultTests | ||
{ | ||
[Fact] | ||
public void CompareTo_WithDifferentAverageScore_ReturnsBestMatch() | ||
{ | ||
// Arrange | ||
var result1 = new RequestMatchResult(); | ||
result1.AddScore(typeof(WildcardMatcher), 1); | ||
result1.AddScore(typeof(WildcardMatcher), 0.9); | ||
|
||
var result2 = new RequestMatchResult(); | ||
result2.AddScore(typeof(LinqMatcher), 1); | ||
result2.AddScore(typeof(LinqMatcher), 1); | ||
|
||
var results = new[] { result1, result2 }; | ||
|
||
// Act | ||
var best = results.OrderBy(x => x).First(); | ||
|
||
// Assert | ||
best.Should().Be(result2); | ||
} | ||
|
||
[Fact] | ||
public void CompareTo_WithSameAverageScoreButMoreMatchers_ReturnsMatchWithMoreMatchers() | ||
{ | ||
// Arrange | ||
var result1 = new RequestMatchResult(); | ||
result1.AddScore(typeof(WildcardMatcher), 1); | ||
result1.AddScore(typeof(WildcardMatcher), 1); | ||
|
||
var result2 = new RequestMatchResult(); | ||
result2.AddScore(typeof(LinqMatcher), 1); | ||
result2.AddScore(typeof(LinqMatcher), 1); | ||
result2.AddScore(typeof(LinqMatcher), 1); | ||
|
||
var results = new[] { result1, result2 }; | ||
|
||
// Act | ||
var best = results.OrderBy(x => x).First(); | ||
|
||
// Assert | ||
best.Should().Be(result2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters