Exemple #1
0
 private static void AddContainsMatcherTo(
     ICanAddMatcher <string> continuation,
     string search
     )
 {
     continuation.AddMatcher(s =>
     {
         var passed = s?.Contains(search) ?? false;
         return(new MatcherResult(
                    passed,
                    MessageHelpers.MessageForContainsResult(
                        passed, s, search
                        )
                    ));
     });
 }
Exemple #2
0
        /// <summary>
        /// Used to test exception messages
        /// </summary>
        /// <param name="src">Continuation carrying an exception message</param>
        /// <param name="search">String to look for in the message</param>
        /// <returns>Another continuation so you can do .And() on it</returns>
        public static IStringContainContinuation Containing(
            this IExceptionMessageContinuation src,
            string search)
        {
            var result = Factory.Create <string, ExceptionMessageContainuationToStringContainContinuation>(
                null, src as IExpectationContext <string>
                );

            src.AddMatcher(s =>
            {
                result.Actual = s;
                var passed    = s?.Contains(search) ?? false;
                return(new MatcherResult(
                           passed,
                           MessageHelpers.MessageForContainsResult(
                               passed, s, search
                               )
                           ));
            });
            return(result);
        }