ExactCountConstraintResult
Contain the result of matching a ExactCountConstraint against an actual value.
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[NullableContext(1)]
[Nullable(0)]
internal sealed class ExactCountConstraintResult : ConstraintResult
{
private readonly int _matchCount;
private readonly ICollection<object> _itemList;
internal ExactCountConstraintResult(IConstraint constraint, [Nullable(2)] object actualValue, bool isSuccess, int matchCount, ICollection<object> itemList)
: base(constraint, actualValue, isSuccess)
{
_matchCount = matchCount;
_itemList = itemList;
}
public override void WriteActualValueTo(MessageWriter writer)
{
if (_itemList == null || _itemList.Count == 0)
writer.Write("no matching items");
else {
writer.Write((_matchCount != 1) ? "{0} matching items " : "{0} matching item ", _matchCount);
writer.Write(MsgUtils.FormatCollection(_itemList, 0, 10));
}
}
}
}