public static void Validate_MatchingTimesOut_ThrowsRegexMatchTimeoutException() { RegularExpressionAttribute attribute = new RegularExpressionAttribute("(a[ab]+)+$") { MatchTimeoutInMilliseconds = 1 }; Assert.Throws <RegexMatchTimeoutException>(() => attribute.Validate("aaaaaaaaaaaaaaaaaaaaaaaaaaaa>", new ValidationContext(new object()))); }
public static void Validate_InvalidMatchTimeoutInMilliseconds_ThrowsArgumentOutOfRangeException(int timeout) { RegularExpressionAttribute attribute = new RegularExpressionAttribute("[^a]+\\.[^z]+") { MatchTimeoutInMilliseconds = 0 }; Assert.Throws <ArgumentOutOfRangeException>("matchTimeout", () => attribute.Validate("a", new ValidationContext(new object()))); }
public static void Validate_InvalidPattern_ThrowsArgumentException() { RegularExpressionAttribute attribute = new RegularExpressionAttribute("foo(?<1bar)"); Assert.Throws<ArgumentException>(null, () => attribute.Validate("Any", new ValidationContext(new object()))); }
public static void Validate_MatchingTimesOut_ThrowsRegexMatchTimeoutException() { RegularExpressionAttribute attribute = new RegularExpressionAttribute("(a+)+$") { MatchTimeoutInMilliseconds = 1 }; Assert.Throws<RegexMatchTimeoutException>(() => attribute.Validate("aaaaaaaaaaaaaaaaaaaaaaaaaaaa>", new ValidationContext(new object()))); }
public static void Validate_InvalidMatchTimeoutInMilliseconds_ThrowsArgumentOutOfRangeException(int timeout) { RegularExpressionAttribute attribute = new RegularExpressionAttribute("[^a]+\\.[^z]+") { MatchTimeoutInMilliseconds = 0 }; Assert.Throws<ArgumentOutOfRangeException>("matchTimeout", () => attribute.Validate("a", new ValidationContext(new object()))); }
public static void Validate_InvalidPattern_ThrowsInvalidOperationException(string pattern) { var attribute = new RegularExpressionAttribute(pattern); Assert.Throws<InvalidOperationException>(() => attribute.Validate("Any", new ValidationContext(new object()))); }
public static void Validate_InvalidPattern_ThrowsInvalidOperationException(string pattern) { var attribute = new RegularExpressionAttribute(pattern); Assert.Throws <InvalidOperationException>(() => attribute.Validate("Any", new ValidationContext(new object()))); }
public static void Validate_InvalidPattern_ThrowsArgumentException() { RegularExpressionAttribute attribute = new RegularExpressionAttribute("foo(?<1bar)"); Assert.ThrowsAny <ArgumentException>(() => attribute.Validate("Any", new ValidationContext(new object()))); }