mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-26 02:08:29 +02:00
Partial matching
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
namespace WireMock.Matchers.Request
|
||||
using System;
|
||||
|
||||
namespace WireMock.Matchers.Request
|
||||
{
|
||||
/// <summary>
|
||||
/// RequestMatchResult
|
||||
/// </summary>
|
||||
public class RequestMatchResult
|
||||
public class RequestMatchResult : IComparable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the number of matches.
|
||||
@@ -27,6 +29,29 @@
|
||||
/// <value>
|
||||
/// <c>true</c> if this instance is perfect match; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public bool IsPerfectMatch { get; set; }
|
||||
public bool IsPerfectMatch => Matched == Total;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the match percentage.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The match percentage.
|
||||
/// </value>
|
||||
public double MatchPercentage => Total == 0 ? 100 : 100.0 * Matched / Total;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
|
||||
/// </summary>
|
||||
/// <param name="obj">An object to compare with this instance.</param>
|
||||
/// <returns>
|
||||
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes <paramref name="obj" /> in the sort order. Zero This instance occurs in the same position in the sort order as <paramref name="obj" />. Greater than zero This instance follows <paramref name="obj" /> in the sort order.
|
||||
/// </returns>
|
||||
/// <exception cref="System.NotImplementedException"></exception>
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
var compareObj = (RequestMatchResult)obj;
|
||||
|
||||
return compareObj.MatchPercentage.CompareTo(MatchPercentage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user