Ejemplo n.º 1
0
 /// <summary>
 /// Asserts that the path is a directory
 /// </summary>
 /// <param name="a"></param>
 public static void Directory(this IA <string> a)
 {
     a.AddMatcher(actual =>
     {
         var passed = System.IO.Directory.Exists(actual);
         return(new MatcherResult(passed, () => $"Expected {actual} {passed.AsNot()}to exist"));
     });
 }
Ejemplo n.º 2
0
 public static void Frog(this IA <object> continuation)
 {
     continuation.AddMatcher(o =>
     {
         var passed  = o is Frog;
         var message = passed ? "Expected not to get a frog": "Expected to get a frog";
         return(new MatcherResult(passed, message));
     });
 }
Ejemplo n.º 3
0
 public static void File(this IA <string> to)
 {
     to.AddMatcher(actual =>
     {
         var passed = System.IO.File.Exists(actual);
         return(new MatcherResult(
                    passed,
                    $"Expected '{actual}' {passed.AsNot()}to be a file"
                    ));
     });
 }
Ejemplo n.º 4
0
 public static IMore <object> Dog(
     this IA <object> continuation)
 {
     return(continuation.AddMatcher(o =>
     {
         var passed = o is Dog;
         return new MatcherResult(
             passed,
             () => $"Expected {passed.AsNot()}to get a dog"
             );
     }));
 }
Ejemplo n.º 5
0
 public static void Flamingo <T>(this IA <T> a)
 {
     a.AddMatcher(item =>
     {
         var asFlamingo = item as Flamingo;
         var passed     = asFlamingo != null &&
                          asFlamingo.Legs == 2 &&
                          asFlamingo.Habitat == Habitats.Wetlands &&
                          asFlamingo.Colors.Contains(Colors.Pink);
         var not = passed
             ? ""
             : "not ";
         return(new MatcherResult(
                    passed,
                    $"Expected {item} {not}to be a flamingo"
                    ));
     });
 }
Ejemplo n.º 6
0
 public static void Penguin <T>(this IA <T> a)
 {
     a.AddMatcher(item =>
     {
         var asPenguin = item as Penguin;
         var passed    = asPenguin != null &&
                         asPenguin.Legs == 2 &&
                         asPenguin.Habitat == Habitats.Polar &&
                         asPenguin.Colors.Contains(Colors.Black) &&
                         asPenguin.Colors.Contains(Colors.White) &&
                         !asPenguin.Colors.Contains(Colors.Pink);
         var not = passed
             ? ""
             : "not ";
         return(new MatcherResult(
                    passed,
                    $"Expected {item} {not}to be a penguin"
                    ));
     });
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Expects the provided path to be a folder
 /// </summary>
 /// <param name="a"></param>
 /// <param name="customMessageGenerator">Generates a custom message to add to failure messages</param>
 /// <returns></returns>
 public static IStringMore Folder(
     this IA <string> a,
     Func <string> customMessageGenerator)
 {
     a.AddMatcher(actual =>
     {
         var passed = System.IO.Directory.Exists(actual);
         var isFile = System.IO.File.Exists(actual);
         var extra  = isFile
             ? " but found a file there instead"
             : " but found nothing";
         return(new MatcherResult(
                    passed,
                    FinalMessageFor(
                        () => $"Expected {actual} {passed.AsNot()}to be a folder{extra}",
                        customMessageGenerator
                        )
                    ));
     });
     return(a.More());
 }