Exemple #1
0
            public void ByDefaultValidateDataAnnotation()
            {
                // By default instance property set to check annotation validation
                var model = new ModelWithoutAnnotation();

                model.Validate(true);

                Assert.AreEqual(1, model.Counter);
            }
Exemple #2
0
            public void OnMethodParamIgnoreDataAnnotationSkipAnnotationValidation()
            {
                var model = new ModelWithoutAnnotation();

                // validate model without data annotations
                model.Validate(true, false);

                Assert.AreEqual(0, model.Counter);
            }
Exemple #3
0
            public void OnInstancePropertyIgnoreDataAnnotationSkipAnnotationValidation()
            {
                // Set intance property to skip data annotations validation
                var model = new ModelWithoutAnnotation();

                model.SetValidateUsingDataAnnotations(false);

                model.Validate(true);

                Assert.AreEqual(0, model.Counter);
            }
Exemple #4
0
            public void OnStaticPropertyIgnoreDataAnnotationSkipAnnotationValidation()
            {
                // store original value
                var oldValue = ModelBase.DefaultValidateUsingDataAnnotationsValue;

                ModelBase.DefaultValidateUsingDataAnnotationsValue = false;
                var model = new ModelWithoutAnnotation();

                model.Validate(true);

                // store original value
                ModelBase.DefaultValidateUsingDataAnnotationsValue = oldValue;

                Assert.AreEqual(0, model.Counter);
            }