public void ByDefaultValidateDataAnnotation() { // By default instance property set to check annotation validation var model = new ModelWithoutAnnotation(); model.Validate(true); Assert.AreEqual(1, model.Counter); }
public void OnMethodParamIgnoreDataAnnotationSkipAnnotationValidation() { var model = new ModelWithoutAnnotation(); // validate model without data annotations model.Validate(true, false); Assert.AreEqual(0, model.Counter); }
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); }
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); }