/// <summary> /// Continues to search for another string after a previous .Contains() /// </summary> /// <param name="continuation"></param> /// <param name="other"></param> /// <param name="customMessage"></param> /// <returns></returns> public static IStringPropertyContinuation Then( this IStringPropertyContinuation continuation, string other, string customMessage) { return(continuation.Then(other, () => customMessage)); }
/// <summary> /// Used to test exception messages /// </summary> /// <param name="src">Continuation containing exception message to test</param> /// <param name="test">Custom function to test the message -- return true if the test should pass</param> /// <param name="customMessageGenerator">Generates a custom message to add to failure messages</param> /// <returns>Another continuation so you can do .And()</returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Func <string, bool> test, Func <string> customMessageGenerator) { var result = ContinuationFactory.Create <string, StringPropertyContinuation>( null, src as IExpectationContext <string> ); src.AddMatcher( s => { result.Actual = s; var passed = test(s); return(new MatcherResult( passed, MessageForMatchResult( passed, s, customMessageGenerator ) )); }); return(result); }
/// <summary> /// Continues to search for another string after a previous .Contains() /// </summary> /// <param name="continuation"></param> /// <param name="other"></param> /// <returns></returns> public static IStringPropertyContinuation Then( this IStringPropertyContinuation continuation, string other ) { return(continuation.Then(other, null as string)); }
/// <summary> /// Used to test exception messages in the negative /// </summary> /// <param name="continuation">Continuation containing the exception message</param> /// <param name="search">String to search for</param> /// <returns>Continuation so you can perform more tests on the message</returns> public static IStringPropertyContinuation Containing( this IStringPropertyContinuation continuation, string search ) { return(continuation.Containing(search, NULL_STRING)); }
/// <summary> /// Used to test exception messages /// </summary> /// <param name="src">Continuation containing exception message to test</param> /// <param name="test">Custom function to test the message -- return true if the test should pass</param> /// <param name="customMessage">Custom message to add to failure messages</param> /// <returns>Another continuation so you can do .And()</returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Func <string, bool> test, string customMessage) { return(src.Matching(test, () => customMessage)); }
/// <summary> /// Used to test exception messages /// </summary> /// <param name="src">Continuation containing exception message to test</param> /// <param name="test">Custom function to test the message -- return true if the test should pass</param> /// <returns>Another continuation so you can do .And()</returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Func <string, bool> test ) { return(src.Matching(test, NULL_STRING)); }
/// <summary> /// Matches a string property with a regular expression /// </summary> /// <param name="src"></param> /// <param name="re"></param> /// <param name="customMessageGenerator"></param> /// <returns></returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Regex re, Func <string> customMessageGenerator ) { var result = ContinuationFactory.Create <string, StringPropertyContinuation>( () => null, src as IExpectationContext <string> ); src.AddMatcher(s => { result.Actual = s; var passed = re.IsMatch(s); return(new MatcherResult( passed, FinalMessageFor( () => $"Expected \"{s}\" {passed.AsNot()}to match regex {PrettyPrint(re)}", customMessageGenerator ) )); }); return(result); }
/// <summary> /// Matches a string property with a regular expression /// </summary> /// <param name="src"></param> /// <param name="re"></param> /// <returns></returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Regex re ) { return(src.Matching(re, NULL_STRING)); }
/// <summary> /// Used to test exception messages in the negative /// </summary> /// <param name="continuation">Continuation containing the exception message</param> /// <param name="search">String to search for</param> /// <param name="customMessageGenerator">Generates a custom message to add to failure messages</param> /// <returns>Continuation so you can perform more tests on the message</returns> public static IStringPropertyContinuation Containing( this IStringPropertyContinuation continuation, string search, Func <string> customMessageGenerator ) { return(RunContainFor(continuation, search, customMessageGenerator, 0)); }
/// <summary> /// Used to test exception messages in the negative /// </summary> /// <param name="continuation">Continuation containing the exception message</param> /// <param name="search">String to search for</param> /// <param name="customMessage">Custom message to add to failure messages</param> /// <returns>Continuation so you can perform more tests on the message</returns> public static IStringPropertyContinuation Containing( this IStringPropertyContinuation continuation, string search, string customMessage ) { return(continuation.Containing(search, () => customMessage)); }
/// <summary> /// Matches a string property with a regular expression /// </summary> /// <param name="src"></param> /// <param name="re"></param> /// <param name="customMessage"></param> /// <returns></returns> public static IStringPropertyContinuation Matching( this IStringPropertyContinuation src, Regex re, string customMessage ) { return(src.Matching(re, () => customMessage)); }
/// <summary> /// /// </summary> /// <param name="continuation"></param> /// <param name="other"></param> /// <param name="messageGenerator"></param> /// <returns></returns> public static IStringPropertyContinuation Then( this IStringPropertyContinuation continuation, string other, Func <string> messageGenerator ) { return(RunContainFor( continuation, other, messageGenerator, other?.GetMetadata <int>(SEARCH_OFFSET) ?? 0)); }
/// <summary> /// Continues to search for another string after a previous .Contains() /// </summary> /// <param name="continuation"></param> /// <param name="other"></param> /// <returns></returns> public static IStringPropertyContinuation And( this IStringPropertyContinuation continuation, string other) { return(continuation.Containing(other)); }