public void OnPropertyValidatedRecordsErrorIfPropertyImplementsIDataErrorInfoAndIsInvalid() {
            // Arrange
            DataErrorInfoProvider model = new DataErrorInfoProvider();
            model.Errors["readwriteproperty"] = "Some error message.";

            ModelBindingContext bindingContext = new ModelBindingContext() {
                Model = model,
                ModelName = "theModel"
            };

            PropertyDescriptor property = TypeDescriptor.GetProperties(typeof(MyModel))["ReadWriteProperty"];
            DefaultModelBinderHelper helper = new DefaultModelBinderHelper();

            // Act
            helper.PublicOnPropertyValidated(null, bindingContext, property, 42);

            // Assert
            Assert.AreEqual("Some error message.", bindingContext.ModelState["themodel.readwriteproperty"].Errors[0].ErrorMessage);
        }
        public void OnPropertyValidatedDoesNothingIfPropertyImplementsIDataErrorInfoAndIsValid() {
            // Arrange
            DataErrorInfoProvider model = new DataErrorInfoProvider();
            ModelBindingContext bindingContext = new ModelBindingContext() {
                Model = model,
                ModelName = "theModel"
            };

            PropertyDescriptor property = TypeDescriptor.GetProperties(typeof(MyModel))["ReadWriteProperty"];
            DefaultModelBinderHelper helper = new DefaultModelBinderHelper();

            // Act
            helper.PublicOnPropertyValidated(null, bindingContext, property, 42);

            // Assert
            Assert.IsTrue(bindingContext.ModelState.IsValidField("themodel.readwriteproperty"), "ModelState should not have been changed.");
        }