public void ValidateInvalid() { Booking model = new Booking { ArrivalDate = new DateTime(2011, 6, 4) }; _validator.ModelType = model.GetType().AssemblyQualifiedName; // we need a naming container ContainerControl container = new ContainerControl(); ModelPropertyValidator propertyValidator = new ModelPropertyValidator { ModelType = _validator.ModelType, PropertyName = "ArrivalDate", ControlToValidate = "txtArrivalDate" }; _validatorCollection.Add(propertyValidator); container.Controls.Add(propertyValidator); container.Controls.Add(_validator); _validator.Validate(); Assert.That(_validator.IsValid, Is.False); Assert.That(_validatorCollection.Count, Is.EqualTo(2)); }
public void SetUp() { _mockValidationRunner = new Mock <IValidationRunner>(); _mockRuleProvider = new Mock <IValidationRuleProvider>(); _mockScriptManager = new Mock <IValidationScriptManager>(); _validator = new ModelPropertyValidator( _mockValidationRunner.Object, _mockRuleProvider.Object, _mockScriptManager.Object); }