Пример #1
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="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 IStringPropertyNot continuation,
            string search,
            Func <string> customMessageGenerator
            )
        {
            var result = ContinuationFactory.Create <string, StringPropertyContinuation>(
                null,
                continuation as IExpectationContext <string>
                );

            continuation.AddMatcher(
                s =>
            {
                result.Actual = s;
                var passed    = s?.Contains(search) ?? true;
                return(new MatcherResult(
                           passed,
                           MessageForNotContainsResult(
                               passed,
                               s,
                               search,
                               customMessageGenerator
                               )
                           ));
            });
            return(result);
        }
Пример #2
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>
 /// <returns>Continuation so you can perform more tests on the message</returns>
 public static IStringPropertyContinuation Containing(
     this IStringPropertyNot continuation,
     string search
     )
 {
     return(continuation.Containing(search, NULL_STRING));
 }
Пример #3
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 IStringPropertyNot continuation,
     string search,
     string customMessage
     )
 {
     return(continuation.Containing(search, () => customMessage));
 }