Exemple #1
0
 public static AssertCollection <T> HaveCount <T>(this AssertCollection <T> assertCollection, int expectedCount)
 {
     if (expectedCount != assertCollection.Collection.Count)
     {
         throw new AssertFailedException($"Expected {expectedCount} elements, but the collection had {assertCollection.Collection.Count}");
     }
     return(assertCollection);
 }
Exemple #2
0
 public static AssertCollection <T> And <T>(this AssertCollection <T> assertCollection)
 {
     return(assertCollection);
 }
Exemple #3
0
 public static AssertCollection <T> Have <T>(this AssertCollection <T> assertCollection, Func <T, bool> assertions)
 {
     return(Are(assertCollection, assertions));
 }
Exemple #4
0
 /// <summary>
 /// Make sure that at least one element of a collection matches the specified criteria in the function
 /// </summary>
 /// <typeparam name="T">Generic type for the collection</typeparam>
 /// <param name="assertCollection"></param>
 /// <param name="assertions">Function which must return true to succeed validation</param>
 /// <returns></returns>
 public static AssertCollection <T> Contains <T>(this AssertCollection <T> assertCollection, Func <T, bool> assertions)
 {
     Assert.IsTrue(assertCollection.Collection.Any(assertions));
     return(assertCollection);
 }
Exemple #5
0
 /// <summary>
 /// Make sure that each element of a collection matches the specified criteria in the function
 /// </summary>
 /// <typeparam name="T">Generic type for the collection</typeparam>
 /// <param name="assertCollection"></param>
 /// <param name="assertions">Function which must return true to succeed validation</param>
 /// /// <returns></returns>
 public static AssertCollection <T> Are <T>(this AssertCollection <T> assertCollection, Func <T, bool> assertions)
 {
     Assert.IsTrue(assertCollection.Collection.All(assertions));
     return(assertCollection);
 }
Exemple #6
0
 public static AssertCollection <T> IsNotNullOrEmpty <T>(this AssertCollection <T> assertCollection)
 {
     Assert.IsNotNull(assertCollection.Collection, "The collection is null");
     Assert.IsTrue(assertCollection.Collection.Any(), "The collection is empty");
     return(assertCollection);
 }
Exemple #7
0
 public static AssertCollection <T> IsNotNull <T>(this AssertCollection <T> assertCollection)
 {
     Assert.IsNotNull(assertCollection.Collection);
     return(assertCollection);
 }