| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace WireMock.Matchers.Request |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// RequestMatchResult |
| | | 7 | | /// </summary> |
| | | 8 | | public class RequestMatchResult : IComparable |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets or sets the match-score. |
| | | 12 | | /// </summary> |
| | | 13 | | /// <value> |
| | | 14 | | /// The match-score. |
| | | 15 | | /// </value> |
| | 140 | 16 | | public double TotalScore { get; set; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets the total number of matches. |
| | | 20 | | /// </summary> |
| | | 21 | | /// <value> |
| | | 22 | | /// The total number of matches. |
| | | 23 | | /// </value> |
| | 142 | 24 | | public int TotalNumber { get; set; } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets or sets a value indicating whether this instance is perfect match. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <value> |
| | | 30 | | /// <c>true</c> if this instance is perfect match; otherwise, <c>false</c>. |
| | | 31 | | /// </value> |
| | 8 | 32 | | public bool IsPerfectMatch => Math.Abs(TotalScore - TotalNumber) < MatchScores.Tolerance; |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Gets the match percentage. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <value> |
| | | 38 | | /// The match percentage. |
| | | 39 | | /// </value> |
| | 2 | 40 | | public double AverageTotalScore => TotalNumber == 0 ? 0.0 : TotalScore / TotalNumber; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Compares the current instance with another object of the same type and returns an integer that indicates whe |
| | | 44 | | /// </summary> |
| | | 45 | | /// <param name="obj">An object to compare with this instance.</param> |
| | | 46 | | /// <returns> |
| | | 47 | | /// A value that indicates the relative order of the objects being compared. The return value has these meanings |
| | | 48 | | /// </returns> |
| | | 49 | | /// <exception cref="System.NotImplementedException"></exception> |
| | | 50 | | public int CompareTo(object obj) |
| | 0 | 51 | | { |
| | 0 | 52 | | var compareObj = (RequestMatchResult)obj; |
| | | 53 | | |
| | 0 | 54 | | return compareObj.AverageTotalScore.CompareTo(AverageTotalScore); |
| | 0 | 55 | | } |
| | | 56 | | } |
| | | 57 | | } |