Partial matching

This commit is contained in:
Stef Heyenrath
2017-02-04 17:30:16 +01:00
parent 9b99a7f26b
commit ec2d105db2
19 changed files with 343 additions and 83 deletions

View File

@@ -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);
}
}
}