public void ClosingDateTwoWeeksAway_PossibleStartDateAfterClosingDate() { var today = DateTime.Today; var viewModel = new FurtherVacancyDetailsViewModel { VacancyDatesViewModel = new VacancyDatesViewModel { ClosingDate = new DateViewModel(today.AddDays(14)), PossibleStartDate = new DateViewModel(today.AddDays(15)) }, Wage = new WageViewModel() }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).Build(); _validator.Validate(viewModel, ruleSet: RuleSet); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyDatesViewModel.ClosingDate, viewModel, RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyDatesViewModel.PossibleStartDate, viewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel.ClosingDate, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel.ClosingDate, vacancyViewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel.PossibleStartDate, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel.PossibleStartDate, vacancyViewModel, RuleSet); }
public void OfflineApplicationUrlNotRequired(OfflineVacancyType?offlineVacancyType, bool expectValid) { var viewModel = new NewVacancyViewModel { OfflineVacancy = true, OfflineVacancyType = offlineVacancyType, OfflineApplicationUrl = null }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).With(_furtherDetailsViewModel).Build(); _validator.Validate(viewModel); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Errors); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Warnings); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.ErrorsAndWarnings); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.OfflineApplicationUrl, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.ErrorsAndWarnings); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.OfflineApplicationUrl, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.OfflineApplicationUrl, vacancyViewModel, RuleSets.ErrorsAndWarnings); } }
public void FirstQuestionValidation(string firstQuestion, bool expectValid) { var viewModel = new VacancyQuestionsViewModel { FirstQuestion = firstQuestion }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).With(_furtherVacancyDetailsViewModel).Build(); _validator.Validate(viewModel); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Errors); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Warnings); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.ErrorsAndWarnings); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.FirstQuestion, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.ErrorsAndWarnings); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.FirstQuestion, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyQuestionsViewModel, vm => vm.VacancyQuestionsViewModel.FirstQuestion, vacancyViewModel, RuleSets.ErrorsAndWarnings); } }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { var validator = new VacancyViewModelValidator(); var result = validator.Validate(this); return(result.Errors.Select(item => new ValidationResult(item.ErrorMessage, new[] { item.PropertyName }))); }
public MediatorResponse <VacancyViewModel> ReviewVacancy(int vacancyReferenceNumber) { var vacancyViewModel = _vacancyQaProvider.ReviewVacancy(vacancyReferenceNumber); if (vacancyViewModel == null) { return(GetMediatorResponse <VacancyViewModel>(VacancyMediatorCodes.ReviewVacancy.InvalidVacancy, null, VacancyViewModelMessages.InvalidVacancy, UserMessageLevel.Error)); } vacancyViewModel.IsManageReviewerView = true; vacancyViewModel.IsEditable = vacancyViewModel.Status.IsStateReviewable(); var validationResult = _vacancyViewModelValidator.Validate(vacancyViewModel); if (!validationResult.IsValid) { switch (vacancyViewModel.VacancySource) { case VacancySource.Av: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.VacancyAuthoredInAvmsWithValidationErrors, vacancyViewModel, validationResult, VacancyViewModelMessages.VacancyAuthoredInAvms, UserMessageLevel.Info)); case VacancySource.Api: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.VacancyAuthoredInApiWithValidationErrors, vacancyViewModel, validationResult, VacancyViewModelMessages.VacancyAuthoredInApi, UserMessageLevel.Info)); case VacancySource.Raa: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.FailedValidation, vacancyViewModel, validationResult)); default: throw new ArgumentOutOfRangeException(); } } switch (vacancyViewModel.VacancySource) { case VacancySource.Av: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.VacancyAuthoredInAvms, vacancyViewModel, VacancyViewModelMessages.VacancyAuthoredInAvms, UserMessageLevel.Info)); case VacancySource.Api: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.VacancyAuthoredInApi, vacancyViewModel, VacancyViewModelMessages.VacancyAuthoredInApi, UserMessageLevel.Info)); case VacancySource.Raa: return(GetMediatorResponse(VacancyMediatorCodes.ReviewVacancy.Ok, vacancyViewModel)); default: throw new ArgumentOutOfRangeException(); } }
[TestCase(2574, WageUnit.Annually, 15, true)] //3.30 pounds per hour public void ApprenticeMinimumWage_PerHour_BeforeOctFirst2016(decimal wage, WageUnit wageUnit, decimal hoursPerWeek, bool expectValid) { var viewModel = new FurtherVacancyDetailsViewModel { Wage = new WageViewModel() { Classification = WageClassification.Custom, CustomType = CustomWageType.Fixed, Amount = wage, Unit = wageUnit, HoursPerWeek = hoursPerWeek }, VacancyDatesViewModel = new VacancyDatesViewModel { PossibleStartDate = new DateViewModel(new DateTime(2016, 9, 30)) } }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).Build(); var response = _validator.Validate(viewModel, ruleSet: RuleSet); _aggregateValidator.Validate(vacancyViewModel); var aggregateResponse = _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSet); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.Wage, vm => vm.Wage.Amount, viewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.Amount, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.Amount, vacancyViewModel, RuleSet); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.Wage, vm => vm.Wage.Amount, viewModel, RuleSet); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.Amount, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.Amount, vacancyViewModel, RuleSet); var error = response.Errors.SingleOrDefault(e => e.PropertyName == "Wage.Amount"); error.Should().NotBeNull(); error?.ErrorMessage.Should().Be("The wage should not be less than the National Minimum Wage for apprentices"); var aggregateError = aggregateResponse.Errors.SingleOrDefault(e => e.PropertyName == "FurtherVacancyDetailsViewModel.Wage.Amount"); aggregateError.Should().NotBeNull(); aggregateError?.ErrorMessage.Should().Be("The wage should not be less than the National Minimum Wage for apprentices"); } }
public void RuleFour_HoursPerWeek16to30_And_DurationGreaterThanOrEqualTo12months_And_ExpectedDurationGreaterThanOrEqualToMinimumDuration(decimal hoursPerWeek, int expectedDuration, DurationType durationType) { var viewModel = new FurtherVacancyDetailsViewModel { Wage = new WageViewModel() { CustomType = CustomWageType.Fixed, HoursPerWeek = hoursPerWeek }, Duration = expectedDuration, DurationType = durationType }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).Build(); _validator.Validate(viewModel, ruleSet: RuleSet); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.Wage, vm => vm.Wage.HoursPerWeek, viewModel, RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.Duration, viewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.HoursPerWeek, vacancyViewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel. Duration, vacancyViewModel, RuleSet); }
public void VacancyTypeRequired(VacancyType vacancyType, bool expectValid) { var viewModel = new NewVacancyViewModel { VacancyType = vacancyType }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).With(_furtherDetailsViewModel).Build(); _validator.Validate(viewModel); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Errors); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Warnings); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.ErrorsAndWarnings); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyType, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.ErrorsAndWarnings); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.VacancyType, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.VacancyType, vacancyViewModel, RuleSets.ErrorsAndWarnings); } }
public void RuleOne_HoursPerWeek30to40_And_DurationGreaterOrEqualTo12months(decimal hoursPerWeek, int expectedDuration, DurationType durationType) { var viewModel = new FurtherVacancyDetailsViewModel { Wage = new WageViewModel() { HoursPerWeek = hoursPerWeek }, Duration = expectedDuration, DurationType = durationType }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).Build(); _validator.Validate(viewModel, ruleSet: RuleSet); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.Wage, vm => vm.Wage.HoursPerWeek, viewModel, RuleSet); _validator.ShouldNotHaveValidationErrorFor(vm => vm.Duration, viewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.HoursPerWeek, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Wage, vm => vm.FurtherVacancyDetailsViewModel.Wage.HoursPerWeek, vacancyViewModel, RuleSet); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Duration, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.Duration, vacancyViewModel, RuleSet); }
public void VacancyViewModelValidatorDefaultShouldHaveMultipleValidationErrors() { var datesViewModel = new VacancyDatesViewModel(); var vacancyViewModel = new VacancyViewModelBuilder().With(datesViewModel).With(_wageViewModel).Build(); var result = _vacancyValidator.Validate(vacancyViewModel, ruleSet: RuleSet); result.IsValid.Should().BeFalse(); result.Errors.Count.Should().BeGreaterThan(1); }
public void DesiredSkillsValidation(string desiredSkills, bool expectValid) { var viewModel = new VacancyRequirementsProspectsViewModel { DesiredSkills = desiredSkills, VacancySource = VacancySource.Raa }; var vacancyViewModel = new VacancyViewModelBuilder().With(_furtherDetailsViewModel).With(viewModel).Build(); _validator.Validate(viewModel); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Errors); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Warnings); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.ErrorsAndWarnings); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.DesiredSkills, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.ErrorsAndWarnings); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.DesiredSkills, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.VacancyRequirementsProspectsViewModel, vm => vm.VacancyRequirementsProspectsViewModel.DesiredSkills, vacancyViewModel, RuleSets.ErrorsAndWarnings); } }
public void ShouldRequireApprenticeshipLevel(ApprenticeshipLevel apprenticeshipLevel, TrainingType trainingType, bool expectValid) { // Arrange. var viewModel = new TrainingDetailsViewModel { TrainingType = trainingType, ApprenticeshipLevel = apprenticeshipLevel }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).With(_furtherDetailsViewModel).Build(); // Act. _validator.Validate(viewModel); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Errors); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.Warnings); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSets.ErrorsAndWarnings); // Assert. if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(m => m.ApprenticeshipLevel, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.ErrorsAndWarnings); } else { _validator.ShouldHaveValidationErrorFor(m => m.ApprenticeshipLevel, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.TrainingDetailsViewModel, vm => vm.TrainingDetailsViewModel.ApprenticeshipLevel, vacancyViewModel, RuleSets.ErrorsAndWarnings); } }
public void ClosingDateInThePastWarning() { var viewModel = new VacancyDatesViewModel { ClosingDate = new DateViewModel(DateTime.Today.AddDays(-7)) }; var vacancyViewModel = new VacancyViewModelBuilder().With(viewModel).With(_wageViewModel).Build(); _serverWarningValidator.Validate(viewModel, ruleSet: RuleSet); _aggregateValidator.Validate(vacancyViewModel); _aggregateValidator.Validate(vacancyViewModel, ruleSet: RuleSet); _serverWarningValidator.ShouldHaveValidationErrorFor(vm => vm.ClosingDate, viewModel, RuleSet); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.FurtherVacancyDetailsViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel, vm => vm.FurtherVacancyDetailsViewModel.VacancyDatesViewModel.ClosingDate, vacancyViewModel, RuleSet); }