Exemplo n.º 1
0
            public void SuspendsValidationsAndValidatesOnResumeWithScopes()
            {
                var model = new SuspendableTestModel();

                using (model.SuspendValidations())
                {
                    using (model.SuspendValidations())
                    {
                        model.Validate(true, true);

                        var innerValidationContext1 = model.GetValidationContext();

                        Assert.IsFalse(innerValidationContext1.HasErrors);
                    }

                    var innerValidationContext2 = model.GetValidationContext();

                    Assert.IsFalse(innerValidationContext2.HasErrors);
                }

                var validationContext = model.GetValidationContext();
                var errors            = validationContext.GetErrors();

                Assert.IsTrue(validationContext.HasErrors);
                Assert.AreEqual("FirstName", ((FieldValidationResult)errors[0]).PropertyName);
                Assert.AreEqual("LastName", ((FieldValidationResult)errors[1]).PropertyName);
            }
Exemplo n.º 2
0
            public void CorrectlyValidates()
            {
                var model = new SuspendableTestModel();

                model.Validate(true, true);

                var validationContext = model.GetValidationContext();
                var errors            = validationContext.GetErrors();

                Assert.IsTrue(validationContext.HasErrors);
                Assert.AreEqual("FirstName", ((FieldValidationResult)errors[0]).PropertyName);
                Assert.AreEqual("LastName", ((FieldValidationResult)errors[1]).PropertyName);
            }