Пример #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)));
 }
Пример #2
0
 public static IMatcher <T[]> NotNull <T>()
 {
     return(Matchers.Function((T[] actual) => actual != null, "a non null array of " + typeof(T).Name));
 }
Пример #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));
 }
Пример #4
0
 public static IMatcher <float?> NotNull()
 {
     return(Matchers.Function((float?actual) => actual != null, "a non null float"));
 }
Пример #5
0
 public static IMatcher <float?> Not(float expect)
 {
     return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) != 0, "a float != " + expect.ToPrettyString()));
 }
Пример #6
0
 public static IMatcher <double?> LessThanOrEqualTo(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) >= 0, "a double <= " + expect.ToPrettyString()));
 }
Пример #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()));
 }
Пример #8
0
 public static IMatcher <string> Not(IMatcher <string> matcher)
 {
     return(Matchers.Not(matcher));
 }
Пример #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() + "'"));
 }
Пример #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 + "'"));
 }
Пример #11
0
 public static IMatcher <string> Containing(string expect)
 {
     return(Matchers.Function((string actual) => actual != null && actual.Contains(expect), "a string containing '" + expect + "'"));
 }
Пример #12
0
 public static IMatcher <Uri> NotNull()
 {
     return(Matchers.Function((Uri actual) => actual != null, "a non null uri"));
 }
Пример #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));
 }
Пример #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));
 }
Пример #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"));
 }
Пример #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 + "'"));
 }
Пример #17
0
 public static IMatcher <double?> GreaterThan(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) < 0, "a double > " + expect.ToPrettyString()));
 }
Пример #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 + "'"));
 }
Пример #19
0
 public static IMatcher <double?> Not(double expect)
 {
     return(Matchers.Function((double?actual) => actual.IsValidDouble() && actual != expect, "a double != " + expect.ToPrettyString()));
 }
Пример #20
0
 public static IMatcher <string> StartingWith(string expect)
 {
     return(Matchers.Function((string actual) => actual != null && actual.StartsWith(expect), "a string starting with '" + expect + "'"));
 }
Пример #21
0
 public static IMatcher <double?> NotNull()
 {
     return(Matchers.Function((double?actual) => actual != null, "a non null double"));
 }
Пример #22
0
 public static IMatcher <string> NotNull()
 {
     return(Matchers.Function((string actual) => actual != null, "a non null string"));
 }
Пример #23
0
 public static IMatcher <float?> LessThanOrEqualTo(float expect)
 {
     return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) >= 0, "a float <= " + expect.ToPrettyString()));
 }
Пример #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"));
 }
Пример #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()));
 }
Пример #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"));
 }
Пример #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));
 }
Пример #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"));
 }
Пример #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));
 }
Пример #30
0
 public static IMatcher <T> Any <T>()
 {
     return(Matchers.Function((T t) => true, "Any " + typeof(T).FullName));
 }