mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-17 15:46:46 +01:00
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
82 lines
2.3 KiB
C#
82 lines
2.3 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System.Linq;
|
|
using Stef.Validation;
|
|
|
|
namespace WireMock.Matchers;
|
|
|
|
/// <summary>
|
|
/// ExactObjectMatcher
|
|
/// </summary>
|
|
/// <seealso cref="IObjectMatcher" />
|
|
public class ExactObjectMatcher : IObjectMatcher
|
|
{
|
|
/// <inheritdoc />
|
|
public object Value { get; }
|
|
|
|
/// <inheritdoc />
|
|
public MatchBehaviour MatchBehaviour { get; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="value">The value.</param>
|
|
public ExactObjectMatcher(object value) : this(MatchBehaviour.AcceptOnMatch, value)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
/// <param name="value">The value.</param>
|
|
public ExactObjectMatcher(MatchBehaviour matchBehaviour, object value)
|
|
{
|
|
Value = Guard.NotNull(value);
|
|
MatchBehaviour = matchBehaviour;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="value">The value.</param>
|
|
public ExactObjectMatcher(byte[] value) : this(MatchBehaviour.AcceptOnMatch, value)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="ExactObjectMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
/// <param name="value">The value.</param>
|
|
public ExactObjectMatcher(MatchBehaviour matchBehaviour, byte[] value)
|
|
{
|
|
Value = Guard.NotNull(value);
|
|
MatchBehaviour = matchBehaviour;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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 MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(equals));
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string Name => nameof(ExactObjectMatcher);
|
|
|
|
/// <inheritdoc />
|
|
public string GetCSharpCodeArguments()
|
|
{
|
|
return "NotImplemented";
|
|
}
|
|
} |