CollectionEquivalentConstraintResult
Provides a ConstraintResult for the CollectionEquivalentConstraint.
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class CollectionEquivalentConstraintResult : ConstraintResult
{
private readonly CollectionTally.CollectionTallyResult _tallyResult;
public CollectionEquivalentConstraintResult(CollectionEquivalentConstraint constraint, CollectionTally.CollectionTallyResult tallyResult, [System.Runtime.CompilerServices.Nullable(2)] object actual, bool isSuccess)
: base(constraint, actual, isSuccess)
{
Guard.ArgumentNotNull(tallyResult, "tallyResult");
_tallyResult = tallyResult;
}
public override void WriteAdditionalLinesTo(MessageWriter writer)
{
DefaultInterpolatedStringHandler defaultInterpolatedStringHandler;
if (_tallyResult.MissingItems.Count > 0) {
int count = _tallyResult.MissingItems.Count;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(12, 1);
defaultInterpolatedStringHandler.AppendLiteral("Missing (");
defaultInterpolatedStringHandler.AppendFormatted(count);
defaultInterpolatedStringHandler.AppendLiteral("): ");
string str = defaultInterpolatedStringHandler.ToStringAndClear();
str += MsgUtils.FormatCollection(_tallyResult.MissingItems, 0, 10);
writer.WriteMessageLine(str, Array.Empty<object>());
}
if (_tallyResult.ExtraItems.Count > 0) {
int count2 = _tallyResult.ExtraItems.Count;
defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(10, 1);
defaultInterpolatedStringHandler.AppendLiteral("Extra (");
defaultInterpolatedStringHandler.AppendFormatted(count2);
defaultInterpolatedStringHandler.AppendLiteral("): ");
string str2 = defaultInterpolatedStringHandler.ToStringAndClear();
str2 += MsgUtils.FormatCollection(_tallyResult.ExtraItems, 0, 10);
writer.WriteMessageLine(str2, Array.Empty<object>());
}
}
}
}