Summary

Class:WireMock.Matchers.Request.RequestMatchResult
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMatchResult.cs
Covered lines:16
Uncovered lines:0
Coverable lines:16
Total lines:82
Line coverage:100%
Branch coverage:50%

Metrics

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

File(s)

C:\Users\StefHeyenrath\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>
 182217        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>
 186325        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>
 31533        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>
 4041        public double AverageTotalScore => TotalNumber == 0 ? 0.0 : TotalScore / TotalNumber;
 42
 43        /// <summary>
 44        /// Gets the match details.
 45        /// </summary>
 75146        public IList<KeyValuePair<Type, double>> MatchDetails { get; }
 47
 48        /// <summary>
 49        /// Initializes a new instance of the <see cref="RequestMatchResult"/> class.
 50        /// </summary>
 73051        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)
 71660        {
 71661            TotalScore += score;
 71662            TotalNumber++;
 71663            MatchDetails.Add(new KeyValuePair<Type, double>(matcherType, score));
 64
 71665            return score;
 71666        }
 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)
 176        {
 177            var compareObj = (RequestMatchResult)obj;
 78
 179            return compareObj.AverageTotalScore.CompareTo(AverageTotalScore);
 180        }
 81    }
 82}