public void ValidationProviderUnregistersControlsOnDispose() { ValidationProvider validationProvider = new ValidationProvider(); validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName; validationProvider.RulesetName = "validation"; validationProvider.ValidationPerformed += OnValidationPerformed; MockControl control = new MockControl(); validationProvider.SetSourcePropertyName(control, "StringProperty"); validationProvider.SetPerformValidation(control, true); control.Text = "too long"; bool cancel = control.FireValidating(); Assert.IsTrue(cancel); Assert.IsNotNull(validationStatusOnCallback); validationStatusOnCallback = null; validationProvider.Dispose(); cancel = control.FireValidating(); Assert.IsFalse(cancel); Assert.IsNull(validationStatusOnCallback); }
public void AutomaticValidationWillNotBePerformedIfValidationProviderIsDisabled() { ValidationProvider validationProvider = new ValidationProvider(); validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName; validationProvider.RulesetName = "validation"; validationProvider.Enabled = false; // set validation provider to disabled MockControl control1 = new MockControl(); validationProvider.SetSourcePropertyName(control1, "StringProperty"); validationProvider.SetPerformValidation(control1, true); control1.Text = "too long"; bool cancel = control1.FireValidating(); Assert.IsTrue(validationProvider.IsValid); Assert.IsFalse(cancel); }
public void ValidationIsFiredAndCancelArgsIsSetToTrueOnValidatingEventIfExtendedControlDoesAllowValidationAndFails() { ValidationProvider validationProvider = new ValidationProvider(); validationProvider.SourceTypeName = typeof(ValidationProviderFixtureTestClass).AssemblyQualifiedName; validationProvider.RulesetName = "validation"; validationProvider.ValidationPerformed += OnValidationPerformed; MockControl control = new MockControl(); ValidatedControlItem validatedControlItem = new ValidatedControlItem(validationProvider, control); validatedControlItem.SourcePropertyName = "StringProperty"; validatedControlItem.PerformValidation = true; control.Text = "too long"; bool cancel = control.FireValidating(); Assert.IsTrue(cancel); Assert.IsNotNull(validationStatusOnCallback); }