Exemplo n.º 1
0
 public static IMore <IEnumerable <int> > Odds(this ICountMatchContinuation <IEnumerable <int> > continuation)
 {
     return(continuation.AddMatcher(collection =>
     {
         return TestCollection(
             collection,
             continuation.ExpectedCount,
             continuation.GetCountMatchMethod(),
             i => i % 2 == 1,
             passed => $"Expected {collection.LimitedPrint()} {passed.AsNot()}to be only odd numbers"
             );
     }));
 }
Exemplo n.º 2
0
 public static void Odds(this ICountMatchContinuation <IEnumerable <int> > continuation)
 {
     continuation.AddMatcher(collection =>
     {
         var expectedCount = continuation.ExpectedCount;
         var method        = continuation.GetCountMatchMethod();
         // TODO: use count and method
         var count  = collection.Count(i => i % 2 == 1);
         var total  = collection.Count();
         var passed = _strategies[method](total, count, expectedCount);
         return(new MatcherResult(
                    passed,
                    () => $"Expected {collection.LimitedPrint()} {passed.AsNot()}to be only odd numbers"
                    ));
     });
 }
 public static void Odds(this ICountMatchContinuation <IEnumerable <int> > continuation)
 {
     continuation.AddMatcher(collection =>
     {
         var expectedCount = continuation.GetExpectedCount();
         var method        = continuation.GetCountMatchMethod();
         // TODO: use count and method
         var count  = collection.Count(i => i % 2 == 1);
         var total  = collection.Count();
         var passed = _strategies[method](total, count, expectedCount);
         var not    = passed ? "" : "not ";
         return(new MatcherResult(
                    passed,
                    $"Expected {MessageHelpers.CollectionPrint(collection)} {not}to be only odd numbers"
                    ));
     });
 }
Exemplo n.º 4
0
 public static void Birds <T>(this ICountMatchContinuation <IEnumerable <T> > continuation)
 {
     continuation.AddMatcher(collection =>
     {
         var expectedCount = continuation.GetExpectedCount <T>();
         var matchMethod   = continuation.GetCountMatchMethod();
         var total         = collection.Count();
         var count         = collection.Count(o => o is Flamingo || o is Penguin);
         var passed        = _strategies[matchMethod](total, count, expectedCount);
         var not           = passed
             ? ""
             : "not ";
         return(new MatcherResult(
                    passed,
                    $"Expected {not}to match {_messages[matchMethod](expectedCount)} Birds"
                    ));
     });
 }