Exemplo n.º 1
0
        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}.");
        }
Exemplo n.º 2
0
        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++;
            }
        }
Exemplo n.º 3
0
 internal static void Initialize(ICollectionAssert asserter) => _asserter = asserter;
Exemplo n.º 4
0
 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.");
 }
Exemplo n.º 5
0
 public static void Initialize(IAssert asserter, ICollectionAssert collectionAsserter)
 {
     Assert.Initialize(asserter);
     CollectionAssert.Initialize(collectionAsserter);
 }