public void BindHasErrors() {
     ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();
     BindingOperations.SetBinding(host, ValidationErrorsHostBehavior.HasErrorsProperty, new Binding("ValidationHasErrors") { Source = this, Mode = BindingMode.OneWayToSource, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
     host.Errors.Add(new ValidationError(new ExceptionValidationRule(), new Binding()));
     Assert.IsTrue(host.HasErrors);
     Assert.IsTrue(ValidationHasErrors);
 }
 public void ErrorsPropertyCoerce() {
     ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();
     Interaction.GetBehaviors(Window).Add(host);
     EnqueueShowWindow();
     host.Errors = null;
     Assert.IsNotNull(host.Errors);
 }
        public void ErrorsPropertyCoerce()
        {
            ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();

            Interaction.GetBehaviors(Window).Add(host);
            EnqueueShowWindow();
            host.Errors = null;
            Assert.IsNotNull(host.Errors);
        }
        public void BindHasErrors()
        {
            ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();

            BindingOperations.SetBinding(host, ValidationErrorsHostBehavior.HasErrorsProperty, new Binding("ValidationHasErrors")
            {
                Source = this, Mode = BindingMode.OneWayToSource, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            });
            host.Errors.Add(new ValidationError(new ExceptionValidationRule(), new Binding()));
            Assert.IsTrue(host.HasErrors);
            Assert.IsTrue(ValidationHasErrors);
        }
 public void HookEvents() {
     ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();
     host.Errors = new List<ValidationError>();
     Interaction.GetBehaviors(Window).Add(host);
     EnqueueShowWindow();
     Assert.IsFalse(host.HasErrors);
     ValidationErrorEventArgs eventArgs = CreateValidationErrorEventArgs(new ValidationError(new ExceptionValidationRule(), new Binding()), ValidationErrorEventAction.Added);
     Window.RaiseEvent(eventArgs);
     Assert.IsTrue(eventArgs.Handled);
     Assert.IsTrue(host.HasErrors);
     host.Errors = new List<ValidationError>();
     Assert.IsFalse(host.HasErrors);
     host.Errors = new ObservableCollection<ValidationError>();
     Assert.IsFalse(host.HasErrors);
     host.Errors.Add(new ValidationError(new ExceptionValidationRule(), new Binding()));
     Assert.IsTrue(host.HasErrors);
 }
        public void HookEvents()
        {
            ValidationErrorsHostBehavior host = new ValidationErrorsHostBehavior();

            host.Errors = new List <ValidationError>();
            Interaction.GetBehaviors(Window).Add(host);
            EnqueueShowWindow();
            Assert.IsFalse(host.HasErrors);
            ValidationErrorEventArgs eventArgs = CreateValidationErrorEventArgs(new ValidationError(new ExceptionValidationRule(), new Binding()), ValidationErrorEventAction.Added);

            Window.RaiseEvent(eventArgs);
            Assert.IsTrue(eventArgs.Handled);
            Assert.IsTrue(host.HasErrors);
            host.Errors = new List <ValidationError>();
            Assert.IsFalse(host.HasErrors);
            host.Errors = new ObservableCollection <ValidationError>();
            Assert.IsFalse(host.HasErrors);
            host.Errors.Add(new ValidationError(new ExceptionValidationRule(), new Binding()));
            Assert.IsTrue(host.HasErrors);
        }