Esempio n. 1
0
 public static void Child(
     this IContain <Container> contain,
     Sub sub)
 {
     contain.AddMatcher(actual =>
     {
         var passed = (actual?.Subs ?? new Sub[0])
                      .Any(c => c.Name == sub.Name);
         return(new MatcherResult(
                    passed,
                    $"Expected {actual.Stringify()} {passed.AsNot()}to contain sub {sub.Name}"));
     });
 }
Esempio n. 2
0
 public static void Shape(
     this IContain <Rectangle> contain,
     Rectangle other
     )
 {
     contain.AddMatcher(actual =>
     {
         var passed = actual.Left <= other.Left &&
                      actual.Right >= other.Right &&
                      actual.Top <= other.Top &&
                      actual.Bottom >= other.Bottom;
         return(new MatcherResult(
                    passed,
                    () => $"Expected {actual.Stringify()} {passed.AsNot()}to contain {other.Stringify()}"));
     });
 }
Esempio n. 3
0
 public static void Only(
     this IContain <MemoryStream> contain,
     byte[] data)
 {
     contain.AddMatcher(actual =>
     {
         var actualData   = actual.ReadAllBytes();
         var lengthsMatch = actualData.Length == data.Length;
         var passed       = lengthsMatch &&
                            actualData.DeepEquals(data);
         return(new MatcherResult(
                    passed,
                    () => lengthsMatch
                       ? "Stream data matches expected length, but not expected content"
                       : "Stream data does not match expected content at all"
                    ));
     });
 }