Beispiel #1
0
 public static IMatcher <T> NotNull <T>()// where T : class
 {
     return(Matchers.Function((T actual) => actual != null, String.Format("a non null <{0}>", typeof(T).FullName)));
 }
Beispiel #2
0
 public static IMatcher <T[]> NotNull <T>()
 {
     return(Matchers.Function((T[] actual) => actual != null, "a non null array of " + typeof(T).Name));
 }
Beispiel #3
0
 public static IMatcher <T[]> Empty <T>()
 {
     return(Matchers.Function((T[] actual) => actual != null && actual.Length == 0, "a non null empty array of " + typeof(T).Name));
 }
Beispiel #4
0
 public static IMatcher <float?> NotNull()
 {
     return(Matchers.Function((float?actual) => actual != null, "a non null float"));
 }
Beispiel #5
0
 public static IMatcher <float?> Not(float expect)
 {
     return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) != 0, "a float != " + expect.ToPrettyString()));
 }
Beispiel #6
0
 public static IMatcher <double?> LessThanOrEqualTo(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) >= 0, "a double <= " + expect.ToPrettyString()));
 }
Beispiel #7
0
 public static IMatcher <double?> BetweenIncluding(double expectFrom, double expectTo)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && expectFrom.SafeCompareTo(actual) <= 0 && expectTo.SafeCompareTo(actual) >= 0, "a double where " + expectFrom.ToPrettyString() + " <= value <= " + expectTo.ToPrettyString()));
 }
Beispiel #8
0
 public static IMatcher <string> Not(IMatcher <string> matcher)
 {
     return(Matchers.Not(matcher));
 }
Beispiel #9
0
 public static IMatcher <string> MatchingRegex(Regex expect)
 {
     return(Matchers.Function((string actual) => actual != null && expect.IsMatch(actual), "a string matching regex '" + expect.ToString() + "'"));
 }
Beispiel #10
0
 public static IMatcher <string> EqualToIgnoringCase(string expect)
 {
     expect = expect.ToLower();
     return(Matchers.Function((string actual) => actual != null && expect.Equals(actual.ToLower()), "a string, ignoring case, equal to '" + expect + "'"));
 }
Beispiel #11
0
 public static IMatcher <string> Containing(string expect)
 {
     return(Matchers.Function((string actual) => actual != null && actual.Contains(expect), "a string containing '" + expect + "'"));
 }
Beispiel #12
0
 public static IMatcher <Uri> NotNull()
 {
     return(Matchers.Function((Uri actual) => actual != null, "a non null uri"));
 }
Beispiel #13
0
 public static IMatcher <Uri> EqualTo(Uri expect)
 {
     return(Matchers.Function((Uri actual, IMatchDiagnostics diag) => diag.TryMatch(actual, AnInstance.EqualTo(expect)), () => "a uri equal to " + expect));
 }
Beispiel #14
0
 public static IMatcher <Uri> EqualTo(IMatcher <String> fullPathMatcher)
 {
     return(Matchers.Function((Uri actual, IMatchDiagnostics diag) => diag.TryMatch(actual.AbsoluteUri, fullPathMatcher), () => "a uri equal to " + fullPathMatcher));
 }
Beispiel #15
0
 /// <summary>
 /// A string which is not null but empty
 /// </summary>
 public static IMatcher <string> EmptyOrNull()
 {
     return(Matchers.Function((string actual) => actual == null || actual.Length == 0, "an empty or null string"));
 }
Beispiel #16
0
 public static IMatcher <string> ContainingIgnorePunctuationAndCase(string expect)
 {
     expect = RemovePunctuation(expect).ToLower();
     return(Matchers.Function((string actual) => actual != null && RemovePunctuation(actual).ToLower().Contains(expect), "a string containing, ignoring case and punctuation, equal to '" + expect + "'"));
 }
Beispiel #17
0
 public static IMatcher <double?> GreaterThan(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) < 0, "a double > " + expect.ToPrettyString()));
 }
Beispiel #18
0
 public static IMatcher <string> ContainingOfAnyCase(string expect)
 {
     expect = expect.ToLower();
     return(Matchers.Function((string actual) => actual != null && actual.ToLower().Contains(expect), "a string containing, ignoring case, equal to '" + expect + "'"));
 }
Beispiel #19
0
 public static IMatcher <double?> Not(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && actual != expect, "a double != " + expect.ToPrettyString()));
 }
Beispiel #20
0
 public static IMatcher <string> StartingWith(string expect)
 {
     return(Matchers.Function((string actual) => actual != null && actual.StartsWith(expect), "a string starting with '" + expect + "'"));
 }
Beispiel #21
0
 public static IMatcher <double?> NotNull()
 {
     return(Matchers.Function((double?actual) => actual != null, "a non null double"));
 }
Beispiel #22
0
 public static IMatcher <string> NotNull()
 {
     return(Matchers.Function((string actual) => actual != null, "a non null string"));
 }
Beispiel #23
0
 public static IMatcher <float?> LessThanOrEqualTo(float expect)
 {
     return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) >= 0, "a float <= " + expect.ToPrettyString()));
 }
Beispiel #24
0
 /// <summary>
 /// A string which is either null, empty, or only contains whitespace
 /// </summary>
 public static IMatcher <string> Blank()
 {
     return(Matchers.Function((string actual) => string.IsNullOrEmpty(actual) || actual.Trim().Length == 0, "a blank string"));
 }
Beispiel #25
0
 public static IMatcher <float?> BetweenIncluding(float expectFrom, float expectTo)
 {
     return(Matchers.Function((float?actual) => actual.IsValidFloat() && expectFrom.SafeCompareTo(actual) <= 0 && expectTo.SafeCompareTo(actual) >= 0, "a float where " + expectFrom.ToPrettyString() + " <= value <= " + expectTo.ToPrettyString()));
 }
Beispiel #26
0
 /// <summary>
 /// A string which is NOT null, empty, or only contains whitespace
 /// </summary>
 public static IMatcher <string> NotBlank()
 {
     return(Matchers.Function((string actual) => !string.IsNullOrEmpty(actual) && actual.Trim().Length > 0, "a non blank string"));
 }
Beispiel #27
0
 public static IMatcher <T[]> EmptyOrNull <T>()
 {
     return(Matchers.Function((T[] actual) => actual == null || actual.Length == 0, "a null or empty array of " + typeof(T).Name));
 }
Beispiel #28
0
 /// <summary>
 /// A string which is not null but empty
 /// </summary>
 public static IMatcher <string> Empty()
 {
     return(Matchers.Function((string actual) => actual != null && actual.Length == 0, "an empty non null string"));
 }
Beispiel #29
0
 /// <summary>
 /// Returns a matcher which requires all of the provided matchers to
 /// match.
 /// </summary>
 /// <param name="matchers">the matchers to match. Not null</param>
 /// <typeparam name="T">The type of the object to match</typeparam>
 public static IMatcher <T> Of <T>(params IMatcher <T>[] matchers)
 {
     return(Matchers.All <T>(matchers));
 }
Beispiel #30
0
 public static IMatcher <T> Any <T>()
 {
     return(Matchers.Function((T t) => true, "Any " + typeof(T).FullName));
 }