Exemplo n.º 1
0
            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();
            }
Exemplo n.º 2
0
            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
            }