Summary

Class:WireMock.Matchers.Request.RequestMatchResult
Assembly:WireMock.Net
File(s):C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMatchResult.cs
Covered lines:12
Uncovered lines:4
Coverable lines:16
Total lines:82
Line coverage:75%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor()10100100
AddScore(...)10100100
CompareTo(...)1000

File(s)

C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMatchResult.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace WireMock.Matchers.Request
 5{
 6    /// <summary>
 7    /// RequestMatchResult
 8    /// </summary>
 9    public class RequestMatchResult : IComparable
 10    {
 11        /// <summary>
 12        /// Gets or sets the match-score.
 13        /// </summary>
 14        /// <value>
 15        /// The match-score.
 16        /// </value>
 85917        public double TotalScore { get; private set; }
 18
 19        /// <summary>
 20        /// Gets or sets the total number of matches.
 21        /// </summary>
 22        /// <value>
 23        /// The total number of matches.
 24        /// </value>
 86225        public int TotalNumber { get; private set; }
 26
 27        /// <summary>
 28        /// Gets or sets a value indicating whether this instance is perfect match.
 29        /// </summary>
 30        /// <value>
 31        /// <c>true</c> if this instance is perfect match; otherwise, <c>false</c>.
 32        /// </value>
 9833        public bool IsPerfectMatch => Math.Abs(TotalScore - TotalNumber) < MatchScores.Tolerance;
 34
 35        /// <summary>
 36        /// Gets the match percentage.
 37        /// </summary>
 38        /// <value>
 39        /// The match percentage.
 40        /// </value>
 341        public double AverageTotalScore => TotalNumber == 0 ? 0.0 : TotalScore / TotalNumber;
 42
 43        /// <summary>
 44        /// Gets the match details.
 45        /// </summary>
 37946        public IList<KeyValuePair<Type, double>> MatchDetails { get; }
 47
 48        /// <summary>
 49        /// Initializes a new instance of the <see cref="RequestMatchResult"/> class.
 50        /// </summary>
 41851        public RequestMatchResult() => MatchDetails = new List<KeyValuePair<Type, double>>();
 52
 53        /// <summary>
 54        /// Adds the score.
 55        /// </summary>
 56        /// <param name="matcherType">The matcher Type.</param>
 57        /// <param name="score">The score.</param>
 58        /// <returns>The score.</returns>
 59        public double AddScore(Type matcherType, double score)
 37960        {
 37961            TotalScore += score;
 37962            TotalNumber++;
 37963            MatchDetails.Add(new KeyValuePair<Type, double>(matcherType, score));
 64
 37965            return score;
 37966        }
 67
 68        /// <summary>
 69        /// Compares the current instance with another object of the same type and returns an integer that indicates whe
 70        /// </summary>
 71        /// <param name="obj">An object to compare with this instance.</param>
 72        /// <returns>
 73        /// A value that indicates the relative order of the objects being compared. The return value has these meanings
 74        /// </returns>
 75        public int CompareTo(object obj)
 076        {
 077            var compareObj = (RequestMatchResult)obj;
 78
 079            return compareObj.AverageTotalScore.CompareTo(AverageTotalScore);
 080        }
 81    }
 82}