public void IsValidWhen_EmployeeOrStudentAffiliation_IsNotEmpty() { var validator = new UpdateAffiliationValidator(); var model = new UpdateAffiliationForm { EmployeeOrStudentAffiliation = EmployeeOrStudentAffiliate.Neither }; var results = validator.Validate(model); var error = results.Errors.SingleOrDefault(e => e.PropertyName == UpdateAffiliationForm.EmployeeOrStudentAffiliationPropertyName); error.ShouldBeNull(); }
public void IsInvalidWhen_EmployeeOrStudentAffiliation_IsNull() { var validator = new UpdateAffiliationValidator(); var model = new UpdateAffiliationForm { EmployeeOrStudentAffiliation = null }; var results = validator.Validate(model); results.IsValid.ShouldBeFalse(); results.Errors.Count.ShouldBeInRange(1, int.MaxValue); var error = results.Errors.SingleOrDefault(e => e.PropertyName == UpdateAffiliationForm.EmployeeOrStudentAffiliationPropertyName); error.ShouldNotBeNull(); // ReSharper disable PossibleNullReferenceException error.ErrorMessage.ShouldEqual( UpdateAffiliationValidator.FailedBecauseEmployeeOrStudentAffiliationWasEmpty); // ReSharper restore PossibleNullReferenceException }