コード例 #1
0
 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"
                    ));
     });
 }