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))); }
public static IMatcher <T[]> NotNull <T>() { return(Matchers.Function((T[] actual) => actual != null, "a non null array of " + typeof(T).Name)); }
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)); }
public static IMatcher <float?> NotNull() { return(Matchers.Function((float?actual) => actual != null, "a non null float")); }
public static IMatcher <float?> Not(float expect) { return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) != 0, "a float != " + expect.ToPrettyString())); }
public static IMatcher <double?> LessThanOrEqualTo(double expect) { return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) >= 0, "a double <= " + expect.ToPrettyString())); }
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())); }
public static IMatcher <string> Not(IMatcher <string> matcher) { return(Matchers.Not(matcher)); }
public static IMatcher <string> MatchingRegex(Regex expect) { return(Matchers.Function((string actual) => actual != null && expect.IsMatch(actual), "a string matching regex '" + expect.ToString() + "'")); }
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 + "'")); }
public static IMatcher <string> Containing(string expect) { return(Matchers.Function((string actual) => actual != null && actual.Contains(expect), "a string containing '" + expect + "'")); }
public static IMatcher <Uri> NotNull() { return(Matchers.Function((Uri actual) => actual != null, "a non null uri")); }
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)); }
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)); }
/// <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")); }
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 + "'")); }
public static IMatcher <double?> GreaterThan(double expect) { return(Matchers.Function((double?actual) => actual.IsValidDouble() && expect.SafeCompareTo(actual) < 0, "a double > " + expect.ToPrettyString())); }
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 + "'")); }
public static IMatcher <double?> Not(double expect) { return(Matchers.Function((double?actual) => actual.IsValidDouble() && actual != expect, "a double != " + expect.ToPrettyString())); }
public static IMatcher <string> StartingWith(string expect) { return(Matchers.Function((string actual) => actual != null && actual.StartsWith(expect), "a string starting with '" + expect + "'")); }
public static IMatcher <double?> NotNull() { return(Matchers.Function((double?actual) => actual != null, "a non null double")); }
public static IMatcher <string> NotNull() { return(Matchers.Function((string actual) => actual != null, "a non null string")); }
public static IMatcher <float?> LessThanOrEqualTo(float expect) { return(Matchers.Function((float?actual) => actual.IsValidFloat() && expect.SafeCompareTo(actual) >= 0, "a float <= " + expect.ToPrettyString())); }
/// <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")); }
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())); }
/// <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")); }
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)); }
/// <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")); }
/// <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)); }
public static IMatcher <T> Any <T>() { return(Matchers.Function((T t) => true, "Any " + typeof(T).FullName)); }