예제 #1
0
        /// <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 IStringContainContinuation Matching(
            this IExceptionMessageContinuation src,
            Func <string, bool> test)
        {
            var result = Factory.Create <string, ExceptionMessageContainuationToStringContainContinuation>(
                null, src as IExpectationContext <string>
                );

            src.AddMatcher(s =>
            {
                result.Actual = s;
                var passed    = test(s);
                return(new MatcherResult(
                           passed,
                           MessageHelpers.MessageForMatchResult(
                               passed, s
                               )
                           ));
            });
            return(result);
        }