public void OnModelUpdatedDoesNothingIfModelImplementsIDataErrorInfoAndIsValid() {
            // Arrange
            DataErrorInfoProvider model = new DataErrorInfoProvider();
            ModelBindingContext bindingContext = new ModelBindingContext() {
                Model = model,
                ModelName = "theModel"
            };

            DefaultModelBinderHelper helper = new DefaultModelBinderHelper();

            // Act
            helper.PublicOnModelUpdated(null, bindingContext);

            // Assert
            Assert.IsTrue(bindingContext.ModelState.IsValidField("themodel"), "ModelState should not have been changed.");
        }
        public void OnModelUpdatedRecordsErrorIfModelImplementsIDataErrorInfoAndIsInvalid() {
            // Arrange
            DataErrorInfoProvider model = new DataErrorInfoProvider() { ErrorText = "Some error message." };

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

            DefaultModelBinderHelper helper = new DefaultModelBinderHelper();

            // Act
            helper.PublicOnModelUpdated(null, bindingContext);

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

            DefaultModelBinderHelper helper = new DefaultModelBinderHelper();

            // Act
            helper.PublicOnModelUpdated(null, bindingContext);

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