Exemple #1
0
        public void AddedValidatorShouldBeInValidators()
        {
            var o = new object();
            ValidatableViewModel viewModel = GetValidatableViewModel();
            var validator = new SpyValidator();

            validator.Initialize(viewModel.CreateContext(o));
            viewModel.AddValidator(validator);
            validator.Context.ShouldNotBeNull();
            validator.Context.Instance.ShouldEqual(o);
            viewModel.GetValidators().Single(validator1 => validator1 != viewModel.Validator).ShouldEqual(validator);
        }
Exemple #2
0
        public void WhenPropertyChangedInEntityValidatorShouldNotCallValidateMethodFalse()
        {
            var modelToValidate = new ValidatableModel();
            var validator       = new SpyValidator();

            validator.ValidateOnPropertyChanged = false;
            validator.Initialize(new ValidatorContext(modelToValidate, GetServiceProvider()));

            validator.ValidateCount.ShouldEqual(0);
            modelToValidate.OnPropertyChanged(PropertyToValidate, ExecutionMode.None);
            validator.ValidateCount.ShouldEqual(0);
            validator.ValidateAllCount.ShouldEqual(0);
        }
 public void AddedValidatorShouldBeInValidators()
 {
     var o = new object();
     ValidatableViewModel viewModel = GetValidatableViewModel();
     var validator = new SpyValidator();
     validator.Initialize(viewModel.CreateContext(o));
     viewModel.AddValidator(validator);
     validator.Context.ShouldNotBeNull();
     validator.Context.Instance.ShouldEqual(o);
     viewModel.GetValidators().Single(validator1 => validator1 != viewModel.Validator).ShouldEqual(validator);
 }
        public void WhenPropertyChangedInEntityValidatorShouldNotCallValidateMethodFalse()
        {
            var modelToValidate = new ValidatableModel();
            var validator = new SpyValidator();
            validator.ValidateOnPropertyChanged = false;
            validator.Initialize(new ValidatorContext(modelToValidate, GetServiceProvider()));

            validator.ValidateCount.ShouldEqual(0);
            modelToValidate.OnPropertyChanged(PropertyToValidate, ExecutionMode.None);
            validator.ValidateCount.ShouldEqual(0);
            validator.ValidateAllCount.ShouldEqual(0);
        }