/// <summary> /// Asserts that a string does not match the regex. /// </summary> public AndConstraint <StringAssertions> NotMatch(Regex regex, string because = "", params object[] becauseArgs) { AssertionExtensions.ThrowIfArgumentIsNull(regex, nameof(regex), "Cannot match string against <null>. Provide valid regex."); Execute.Assertion .ForCondition(!regex.IsMatch(Subject)) .BecauseOf(because, becauseArgs) .FailWith("Regex {1} matched {0}{reason}.", Subject, regex); return(new(this)); }
/// <summary> /// Asserts that a string does not contain another (fragment of a) string. /// </summary> /// <param name="unexpected"> /// The (fragment of a) string that the current string should not contain. /// </param> /// <param name="comparison">Comparison used for string.Contains</param> /// <param name="because"> /// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion /// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically. /// </param> /// <param name="becauseArgs"> /// Zero or more objects to format using the placeholders in <paramref name="because" />. /// </param> public AndConstraint <StringAssertions> NotContain(char unexpected, StringComparison comparison, string because = "", params object[] becauseArgs) { AssertionExtensions.ThrowIfArgumentIsNull(unexpected, nameof(unexpected), "Cannot assert string containment against <null>."); Execute.Assertion .ForCondition(!Contains(Subject, unexpected, comparison)) .BecauseOf(because, becauseArgs) .FailWith("Did not expect {context:string} {0} to contain {1}{reason}.", Subject, unexpected); return(new AndConstraint <StringAssertions>(this)); }