// Copyright © WireMock.Net
using System.Linq;
using Stef.Validation;
namespace WireMock.Matchers;
///
/// ExactObjectMatcher
///
///
public class ExactObjectMatcher : IObjectMatcher
{
///
public object Value { get; }
///
public MatchBehaviour MatchBehaviour { get; }
///
/// Initializes a new instance of the class.
///
/// The value.
public ExactObjectMatcher(object value) : this(MatchBehaviour.AcceptOnMatch, value)
{
}
///
/// Initializes a new instance of the class.
///
/// The match behaviour.
/// The value.
public ExactObjectMatcher(MatchBehaviour matchBehaviour, object value)
{
Value = Guard.NotNull(value);
MatchBehaviour = matchBehaviour;
}
///
/// Initializes a new instance of the class.
///
/// The value.
public ExactObjectMatcher(byte[] value) : this(MatchBehaviour.AcceptOnMatch, value)
{
}
///
/// Initializes a new instance of the class.
///
/// The match behaviour.
/// The value.
public ExactObjectMatcher(MatchBehaviour matchBehaviour, byte[] value)
{
Value = Guard.NotNull(value);
MatchBehaviour = matchBehaviour;
}
///
public MatchResult IsMatch(object? input)
{
bool equals;
if (Value is byte[] valueAsBytes && input is byte[] inputAsBytes)
{
equals = valueAsBytes.SequenceEqual(inputAsBytes);
}
else
{
equals = Equals(Value, input);
}
return MatchResult.From(Name, MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(equals)));
}
///
public string Name => nameof(ExactObjectMatcher);
///
public string GetCSharpCodeArguments()
{
return "NotImplemented";
}
}