public static void CountEquals <T>(this ICollectionAssert assert, int expectedCount, IEnumerable <T> collection) { Assert.IsNotNull(collection, $"Collection of {typeof(T).Name.QuoteWith("'")} must not be null."); var actualCount = collection.Count(); Assert.AreEqual(expectedCount, actualCount, $"Collection of {typeof(T).Name.QuoteWith("'")} must have {expectedCount} element(s) but found {actualCount}."); }
public static void AreEqual <T>(this ICollectionAssert assert, IEnumerable <T> excpected, IEnumerable <T> actual) { var index = 0; foreach (var zip in excpected.ZipAll(actual, (left, right) => (left, right))) { if (!zip.left.Equals(zip.right)) { Assert.Fail($"Elements at {index} don't match: {zip.left?.ToString()} != {zip.right?.ToString()}"); } index++; } }
internal static void Initialize(ICollectionAssert asserter) => _asserter = asserter;
public static void IsNotEmpty <T>(this ICollectionAssert assert, [CanBeNull] IEnumerable <T> collection) { Assert.IsNotNull(collection, $"Collection of {typeof(T).Name.QuoteWith("'")} must not be null."); Assert.IsTrue(collection.Any(), $"Collection of {typeof(T).Name.QuoteWith("'")} must not be empty."); }
public static void Initialize(IAssert asserter, ICollectionAssert collectionAsserter) { Assert.Initialize(asserter); CollectionAssert.Initialize(collectionAsserter); }