public void Matches_WhenUrlStringMatchesRegex_It_should_not_throw() { const string value = @"http://google.com:8080"; var match = new Regex(@"(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*"); ShouldNotThrow( () => Ensure.That(value, ParamName).Matches(match), () => EnsureArg.Matches(value, match, ParamName)); }
public void Matches_WhenUrlStringDoesNotMatchRegex_ThrowsArgumentException() { const string value = @"incorrect"; var match = new Regex(@"(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*"); ShouldThrow <ArgumentException>( string.Format(ExceptionMessages.Strings_Matches_Failed, value, match), () => Ensure.That(value, ParamName).Matches(match), () => EnsureArg.Matches(value, match, ParamName)); }
public void Matches_WhenUrlStringMatchesRegex_It_should_not_throw() { const string value = @"http://google.com:8080"; var match = new Regex(@"(?<Protocol>\w+):\/\/(?<Domain>[\w@][\w.:@]+)\/?[\w\.?=%&=\-@/$,]*"); var returnedValue = Ensure.That(value, ParamName).Matches(match); AssertReturnedAsExpected(returnedValue, value); Action a = () => EnsureArg.Matches(value, match, ParamName); a.ShouldNotThrow(); }