public static ValueChecker <string> DoesNotMatch([NotNull] this ValueChecker <string> Checker, [NotNull] Regex ExpectedRegEx, string Message = null)
 {
     StringAssert.DoesNotMatch(Checker.ActualValue, ExpectedRegEx,
                               "{0}Указанная строка {1} ошибочно соответствует ожидаемому регулярному выражению {2}",
                               Message.AddSeparator(),
                               Checker.ActualValue,
                               ExpectedRegEx);
     return(Checker);
 }
Example #2
0
    public void StringDoesNotMatchRegexObject()
    {
        Regex  pattern     = new Regex("...");
        string actualValue = "xxx";

        // MSTest
        MSTestStringAssert.DoesNotMatch(actualValue, pattern, "Some context");
        // StringAssert.DoesNotMatch failed. String 'xxx' matches pattern '...'. Some context.

        // NUnit does not support this case.

        // XUnit
        XUnitAssert.DoesNotMatch(pattern, actualValue);
        // Assert.DoesNotMatch() Failure:
        // Regex: ...
        // Value: xxx

        // Fluent does not support this case.

        // Shouldly does not support this case.
    }
 /// <summary>
 /// Tests whether the specified string does not match a regular expression
 /// and throws an exception if the string matches the expression.
 /// </summary>
 /// <param name="value">
 /// The string that is expected not to match <paramref name="pattern"/>.
 /// </param>
 /// <param name="pattern">
 /// The regular expression that <paramref name="value"/> is
 /// expected to not match.
 /// </param>
 /// <param name="message">
 /// The message to include in the exception when <paramref name="value"/>
 /// matches <paramref name="pattern"/>. The message is shown in test
 /// results.
 /// </param>
 /// <exception cref="AssertFailedException">
 /// Thrown if <paramref name="value"/> matches <paramref name="pattern"/>.
 /// </exception>
 public static void DoesNotMatch(string value, Regex pattern, string message)
 {
     StringAssert.DoesNotMatch(value, pattern, message, null);
 }
 /// <summary>
 /// Tests whether the specified string does not match a regular expression
 /// and throws an exception if the string matches the expression.
 /// </summary>
 /// <param name="value">
 /// The string that is expected not to match <paramref name="pattern"/>.
 /// </param>
 /// <param name="pattern">
 /// The regular expression that <paramref name="value"/> is
 /// expected to not match.
 /// </param>
 /// <exception cref="AssertFailedException">
 /// Thrown if <paramref name="value"/> matches <paramref name="pattern"/>.
 /// </exception>
 public static void DoesNotMatch(string value, Regex pattern)
 {
     StringAssert.DoesNotMatch(value, pattern, string.Empty, null);
 }