Summary

Class:WireMock.Matchers.Request.RequestMatchResult
Assembly:WireMock.Net
File(s):C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMatchResult.cs
Covered lines:4
Uncovered lines:4
Coverable lines:8
Total lines:57
Line coverage:50%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
CompareTo(...)1000

File(s)

C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMatchResult.cs

#LineLine coverage
 1using System;
 2
 3namespace 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>
 14016        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>
 14224        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>
 832        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>
 240        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)
 051        {
 052            var compareObj = (RequestMatchResult)obj;
 53
 054            return compareObj.AverageTotalScore.CompareTo(AverageTotalScore);
 055        }
 56    }
 57}