Summary

Class:WireMock.Matchers.ExactObjectMatcher
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\ExactObjectMatcher.cs
Covered lines:24
Uncovered lines:0
Coverable lines:24
Total lines:71
Line coverage:100%
Branch coverage:100%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
IsMatch(...)0011
.ctor(...)0010
.ctor(...)0010
.ctor(...)0010
.ctor(...)0010

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\ExactObjectMatcher.cs

#LineLine coverage
 1using System.Linq;
 2using JetBrains.Annotations;
 3using WireMock.Validation;
 4
 5namespace WireMock.Matchers
 6{
 7    /// <summary>
 8    /// ExactObjectMatcher
 9    /// </summary>
 10    /// <seealso cref="IObjectMatcher" />
 11    public class ExactObjectMatcher : IObjectMatcher
 12    {
 13        private readonly object _object;
 14        private readonly byte[] _bytes;
 15
 16        /// <inheritdoc cref="IMatcher.MatchBehaviour"/>
 517        public MatchBehaviour MatchBehaviour { get; }
 18
 19        /// <summary>
 20        /// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
 21        /// </summary>
 22        /// <param name="value">The value.</param>
 223        public ExactObjectMatcher([NotNull] object value) : this(MatchBehaviour.AcceptOnMatch, value)
 224        {
 225        }
 26
 27        /// <summary>
 28        /// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
 29        /// </summary>
 30        /// <param name="matchBehaviour">The match behaviour.</param>
 31        /// <param name="value">The value.</param>
 432        public ExactObjectMatcher(MatchBehaviour matchBehaviour, [NotNull] object value)
 433        {
 434            Check.NotNull(value, nameof(value));
 35
 436            _object = value;
 437            MatchBehaviour = matchBehaviour;
 438        }
 39
 40        /// <summary>
 41        /// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
 42        /// </summary>
 43        /// <param name="value">The value.</param>
 144        public ExactObjectMatcher([NotNull] byte[] value) : this(MatchBehaviour.AcceptOnMatch, value)
 145        {
 146        }
 47
 48        /// <summary>
 49        /// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
 50        /// </summary>
 51        /// <param name="matchBehaviour">The match behaviour.</param>
 52        /// <param name="value">The value.</param>
 253        public ExactObjectMatcher(MatchBehaviour matchBehaviour, [NotNull] byte[] value)
 254        {
 255            Check.NotNull(value, nameof(value));
 56
 257            _bytes = value;
 258            MatchBehaviour = matchBehaviour;
 259        }
 60
 61        /// <inheritdoc cref="IObjectMatcher.IsMatch"/>
 62        public double IsMatch(object input)
 563        {
 564            bool equals = _object != null ? Equals(_object, input) : _bytes.SequenceEqual((byte[])input);
 565            return MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(equals));
 566        }
 67
 68        /// <inheritdoc cref="IMatcher.Name"/>
 169        public string Name => "ExactObjectMatcher";
 70    }
 71}