Exemple #1
0
            public void PreventsAttributeBasedValidation()
            {
                var model = new SuspendValidationModel();

                Assert.IsFalse(model.HasErrors);

                model.SuspendValidationWrapper = true;
                model.FirstName = null;

                Assert.IsFalse(model.HasErrors);
            }
            public void PreventsAttributeBasedValidation()
            {
                var model      = new SuspendValidationModel();
                var validation = model as IValidatable;

                Assert.IsFalse(validation.HasErrors);

                using (model.SuspendValidations())
                {
                    model.FirstName = null;

                    Assert.IsFalse(validation.HasErrors);
                }
            }
Exemple #3
0
            public void CorrectlyValidatesUnvalidatedPropertiesWhenSetToTrue()
            {
                var model = new SuspendValidationModel();

                Assert.IsFalse(model.HasErrors);

                model.SuspendValidationWrapper = true;
                model.FirstName = null;

                Assert.IsFalse(model.HasErrors);

                model.SuspendValidationWrapper = false;

                Assert.IsTrue(model.HasErrors);
            }
            public void CorrectlyValidatesUnvalidatedPropertiesWhenSetToTrue()
            {
                var model      = new SuspendValidationModel();
                var validation = model;

                Assert.IsFalse(validation.HasErrors);

                using (model.SuspendValidations())
                {
                    model.FirstName = null;

                    Assert.IsFalse(validation.HasErrors);
                }

                Assert.IsTrue(validation.HasErrors);
            }