<PackageReference Include="NUnit" Version="3.0.0-beta-2" />

CollectionContainsConstraint

CollectionContainsConstraint is used to test whether a collection contains an expected object as a member.
using System.Collections; namespace NUnit.Framework.Constraints { public class CollectionContainsConstraint : CollectionItemsEqualConstraint { public override string Description => "collection containing " + MsgUtils.FormatValue(Expected); protected object Expected { get; set; } public CollectionContainsConstraint(object expected) : base(expected) { Expected = expected; base.DisplayName = "Contains"; } protected override bool Matches(IEnumerable actual) { foreach (object item in actual) { if (ItemsEqual(item, Expected)) return true; } return false; } } }