public void ViewModelWithViewModelToModelMappings_ValidateModelsOnInitialization() { var person = new PersonWithDataAnnotations(); var viewModel = new TestViewModel(person, true); Assert.AreNotEqual(0, viewModel.ValidationContext.GetValidationCount()); }
public void ViewModelWithViewModelToModelMappings_DoNotValidateModelsOnInitialization_UpdateViaModel() { var person = new PersonWithDataAnnotations(); var viewModel = new TestViewModel(person, false); Assert.AreEqual(0, person.GetValidationContext().GetValidationCount()); Assert.AreEqual(0, viewModel.GetValidationContext().GetValidationCount()); person.FirstName = null; Assert.AreNotEqual(0, person.GetValidationContext().GetValidationCount()); Assert.AreNotEqual(0, viewModel.GetValidationContext().GetValidationCount()); }
public void ViewModelWithViewModelToModelMappings_DoNotValidateModelsOnInitialization_UpdateViaModel() { var person = new PersonWithDataAnnotations(); var viewModel = new TestViewModel(person, false); Assert.AreEqual(0, person.ValidationContext.GetValidationCount()); Assert.AreEqual(0, viewModel.ValidationContext.GetValidationCount()); person.FirstName = null; Assert.AreNotEqual(0, person.ValidationContext.GetValidationCount()); Assert.AreNotEqual(0, viewModel.ValidationContext.GetValidationCount()); }