public void GivenUrlsList_WhenAbsoluteAndInvalid_ShouldNotPassValidation(string url) { // Fixture setup // Exercise system // Verify outcome Assert.False(UrlHelpers.IsValidUrl(url)); }
public override void Validate() { var errors = new RulesException <CustomAction>(); base.Validate(errors); if (Order < 0) { errors.ErrorFor(a => a.Order, CustomActionStrings.OrderIsNotInRange); } else if (Order > 0 && Action.EntityTypeId > 0 && !CustomActionRepository.IsOrderUnique(Id, Order, Action.EntityTypeId)) { var freeOrder = GetFreeOrder(Action.EntityTypeId); errors.ErrorFor(a => a.Order, string.Format(CustomActionStrings.OrderValueIsNotUniq, freeOrder)); } if (Action.IsInterface && Action.IsWindow) { if (!Action.WindowHeight.HasValue) { errors.ErrorFor(a => a.Action.WindowHeight, CustomActionStrings.WindowHeightIsNotEntered); } else if (!Action.WindowHeight.Value.IsInRange(100, 1000)) { errors.ErrorFor(a => a.Action.WindowHeight, string.Format(CustomActionStrings.WindowHeightIsNotInRange, 100, 1000)); } if (!Action.WindowWidth.HasValue) { errors.ErrorFor(a => a.Action.WindowWidth, CustomActionStrings.WindowWidthIsNotEntered); } else if (!Action.WindowWidth.Value.IsInRange(100, 1000)) { errors.ErrorFor(a => a.Action.WindowWidth, string.Format(CustomActionStrings.WindowWidthIsNotInRange, 100, 1000)); } } if (!UrlHelpers.IsValidUrl(Url)) { errors.ErrorFor(a => a.Url, string.Format(CustomActionStrings.UrlInvalidFormat)); } if (!UrlHelpers.IsValidUrl(IconUrl)) { errors.ErrorFor(a => a.IconUrl, string.Format(CustomActionStrings.IconUrlInvalidFormat)); } if (!errors.IsEmpty) { throw errors; } }