public static IMore <T> Bipedal <T>(
     this IBe <T> be
     ) where T : Animal
 {
     be.Compose(actual =>
     {
         Expect(actual.Legs).To.Equal(2);
     });
     return(be.More());
 }
        internal static IStringMore AllNumeric(
            this IBe <string> be
            )
        {
            be.AddMatcher(actual =>
            {
                var passed = actual.All(c => "0123456789".Contains(c));
                return(new MatcherResult(
                           passed,
                           $"Expected \"{actual}\" {passed.AsNot()}to be all numeric"
                           ));
            });

            return(be.More());
        }
Example #3
0
 /// <summary>
 /// Asserts that a string is alpha
 /// </summary>
 /// <param name="be"></param>
 /// <param name="customMessageGenerator"></param>
 /// <returns></returns>
 public static IStringMore Alpha(
     this IBe <string> be,
     Func <string> customMessageGenerator)
 {
     be.AddMatcher(actual =>
     {
         var passed = actual != null &&
                      actual.All(c => c.IsAlpha());
         return(new MatcherResult(
                    passed,
                    FinalMessageFor(
                        () => $"Expected {actual.Stringify()} {passed.AsNot()}to be alpha",
                        customMessageGenerator)
                    ));
     });
     return(be.More());
 }
 /// <summary>
 /// Tests if a value is null
 /// </summary>
 /// <param name="continuation">Continuation to operate on</param>
 /// <param name="customMessageGenerator">Generates a custom message to include when failing</param>
 /// <typeparam name="T">Type of object being tested</typeparam>
 public static IMore <T> Null <T>(
     this IBe <T> continuation,
     Func <string> customMessageGenerator
     )
 {
     continuation.AddMatcher(
         actual =>
     {
         var passed = actual == null;
         return(new MatcherResult(
                    passed,
                    FinalMessageFor(
                        () => passed
                               ? new[] { "Expected not to get null" }
                               : new[] { "Expected null but got", Quote(actual) },
                        customMessageGenerator)
                    ));
     });
     return(continuation.More());
 }