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 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 ActionResult MultipleOfflineApplicationUrls(NewVacancyViewModel viewModel) { viewModel.OfflineVacancyType = OfflineVacancyType.MultiUrl; var response = _vacancyMediator.UpdateOfflineVacancyType(viewModel); return(HandleBasicDetails(response)); }
public void ShouldHaveAValidUrlIfTheVacancyIsOffline(string url, bool expectValid) { var viewModel = new NewVacancyViewModel { OfflineVacancy = true, OfflineApplicationUrl = url, VacancySource = VacancySource.Raa }; 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.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(m => m.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 ShouldHaveAValidUrlIfTheVacancyIsMultiLocationOffline(string url, bool expectValid) { var viewModel = new NewVacancyViewModel { OfflineVacancy = true, OfflineVacancyType = OfflineVacancyType.MultiUrl, LocationAddresses = new List <VacancyLocationAddressViewModel> { new VacancyLocationAddressViewModel { OfflineApplicationUrl = url }, new VacancyLocationAddressViewModel { OfflineApplicationUrl = url }, new VacancyLocationAddressViewModel { OfflineApplicationUrl = url } }, VacancySource = VacancySource.Raa }; 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) { for (int i = 0; i < viewModel.LocationAddresses.Count; i++) { var index = i; _validator.ShouldNotHaveValidationErrorFor(m => m.LocationAddresses, m => m.LocationAddresses[index].OfflineApplicationUrl, index, viewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.ErrorsAndWarnings); } } else { for (int i = 0; i < viewModel.LocationAddresses.Count; i++) { var index = i; _validator.ShouldHaveValidationErrorFor(m => m.LocationAddresses, m => m.LocationAddresses[index].OfflineApplicationUrl, index, viewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.Errors); _aggregateValidator.ShouldNotHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.Warnings); _aggregateValidator.ShouldHaveValidationErrorFor(vm => vm.NewVacancyViewModel, vm => vm.NewVacancyViewModel.LocationAddresses, vm => vm.NewVacancyViewModel.LocationAddresses[index].OfflineApplicationUrl, index, vacancyViewModel, RuleSets.ErrorsAndWarnings); } } }
public void SetUp() { _validNewVacancyViewModelWithReferenceNumber = new NewVacancyViewModel() { VacancyReferenceNumber = 1, OfflineVacancy = false, VacancyOwnerRelationship = new VacancyOwnerRelationshipViewModel() }; MockVacancyPostingService.Setup(mock => mock.GetVacancyByReferenceNumber(_validNewVacancyViewModelWithReferenceNumber.VacancyReferenceNumber.Value)) .Returns(_existingVacancy); MockVacancyPostingService.Setup(mock => mock.CreateVacancy(It.IsAny <Vacancy>())) .Returns <Vacancy>(v => v); MockReferenceDataService.Setup(mock => mock.GetSectors()) .Returns(new List <Sector> { new Sector { Id = 1, Standards = new List <Standard> { new Standard { Id = 1, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.Intermediate }, new Standard { Id = 2, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.Advanced }, new Standard { Id = 3, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.Higher }, new Standard { Id = 4, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.FoundationDegree }, new Standard { Id = 5, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.Degree }, new Standard { Id = 6, ApprenticeshipSectorId = 1, ApprenticeshipLevel = ApprenticeshipLevel.Masters } } } }); MockProviderService.Setup(s => s.GetVacancyOwnerRelationship(ProviderSiteId, EdsUrn)) .Returns(_vacancyOwnerRelationship); MockProviderService.Setup(s => s.GetVacancyOwnerRelationship(VacancyOwnerRelationshipId, true)) .Returns(_vacancyOwnerRelationship); MockProviderService.Setup(s => s.GetProvider(Ukprn, true)) .Returns(new Provider()); MockEmployerService.Setup(s => s.GetEmployer(EmployerId, It.IsAny <bool>())).Returns(new Fixture().Build <Employer>().Create()); MockMapper.Setup(m => m.Map <Vacancy, NewVacancyViewModel>(It.IsAny <Vacancy>())) .Returns(new NewVacancyViewModel()); }
private static NewVacancyViewModel GetNewVacancyViewModel(int vacancyReferenceNumber, string title) { var vacancyViewModel = new NewVacancyViewModel { OfflineVacancy = false, ShortDescription = "short description", Ukprn = "ukprn", Title = title + "modified", VacancyReferenceNumber = vacancyReferenceNumber }; return(vacancyViewModel); }
public void SetUp() { _validVacancyMinimumDataSansReferenceNumber = new VacancyMinimumData { VacancyOwnerRelationshipId = VacancyOwnerRelationshipId }; _validNewVacancyViewModelSansReferenceNumber = new NewVacancyViewModel { VacancyOwnerRelationship = new VacancyOwnerRelationshipViewModel() { VacancyOwnerRelationshipId = VacancyOwnerRelationshipId, ProviderSiteId = ProviderSiteId, Employer = new EmployerViewModel { EmployerId = EmployerId, EdsUrn = EdsUrn, Address = new AddressViewModel() } }, OfflineVacancy = false, }; _validNewVacancyViewModelWithReferenceNumber = new NewVacancyViewModel { VacancyOwnerRelationship = new VacancyOwnerRelationshipViewModel() { VacancyOwnerRelationshipId = VacancyOwnerRelationshipId, ProviderSiteId = ProviderSiteId, Employer = new EmployerViewModel { EmployerId = EmployerId, EdsUrn = EdsUrn, Address = new AddressViewModel() } }, OfflineVacancy = false, VacancyReferenceNumber = 1, VacancyGuid = Guid.NewGuid() }; MockVacancyPostingService.Setup(mock => mock.CreateVacancy(It.IsAny <Vacancy>())) .Returns <Vacancy>(v => v); MockProviderService.Setup(s => s.GetVacancyOwnerRelationship(ProviderSiteId, EdsUrn)) .Returns(_vacancyOwnerRelationship); MockProviderService.Setup(s => s.GetVacancyOwnerRelationship(VacancyOwnerRelationshipId, true)) .Returns(_vacancyOwnerRelationship); MockEmployerService.Setup(s => s.GetEmployer(EmployerId, true)).Returns(new Fixture().Build <Employer>().Create()); }
public void OfflineVacancyNotRequired(bool?offlineVacancy, bool expectValid) { var viewModel = new NewVacancyViewModel { OfflineVacancy = offlineVacancy }; _validator.Validate(viewModel); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.OfflineVacancy, viewModel); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.OfflineVacancy, viewModel); } }
public void VacancyTypeNotRequired(VacancyType vacancyType, bool expectValid) { var viewModel = new NewVacancyViewModel { VacancyType = vacancyType }; _validator.Validate(viewModel); if (expectValid) { _validator.ShouldNotHaveValidationErrorFor(vm => vm.VacancyType, viewModel); } else { _validator.ShouldHaveValidationErrorFor(vm => vm.VacancyType, viewModel); } }
public void ShouldShowSaveAndExitButton() { var details = new CreateVacancy(); var viewModel = new NewVacancyViewModel { VacancyOwnerRelationship = new VacancyOwnerRelationshipViewModel() { Employer = new EmployerViewModel() { Address = new AddressViewModel() } } }; var view = details.RenderAsHtml(viewModel); view.GetElementbyId("createVacancyAndExit").Should().NotBeNull("Should exists a save and exit button"); }
public MediatorResponse <NewVacancyViewModel> UpdateVacancy(NewVacancyViewModel viewModel, AbstractValidator <NewVacancyViewModel> validator) { var validationResult = validator.Validate(viewModel); if (!validationResult.IsValid) { var locationAddresses = _vacancyQaProvider.GetLocationsAddressViewModelsByReferenceNumber(viewModel.VacancyReferenceNumber.Value); if (viewModel.LocationAddresses != null) { foreach (var locationAddress in locationAddresses) { locationAddress.OfflineApplicationUrl = viewModel.LocationAddresses.SingleOrDefault(la => la.VacancyLocationId == locationAddress.VacancyLocationId)?.OfflineApplicationUrl; } } viewModel.LocationAddresses = locationAddresses; return(GetMediatorResponse(VacancyMediatorCodes.UpdateVacancy.FailedValidation, viewModel, validationResult)); } var updatedViewModel = _vacancyQaProvider.UpdateVacancyWithComments(viewModel); return(ReturnResult(updatedViewModel)); }
public ActionResult BasicDetails(NewVacancyViewModel viewModel) { var response = _vacancyMediator.UpdateVacancy(viewModel); return(HandleBasicDetails(response)); }
public VacancyViewModelBuilder With(NewVacancyViewModel newVacancyViewModel) { _newVacancyViewModel = newVacancyViewModel; return(this); }
public MediatorResponse <NewVacancyViewModel> UpdateOfflineVacancyType(NewVacancyViewModel viewModel) { return(UpdateVacancy(viewModel, _newVacancyViewModelClientValidator)); }
public MediatorResponse <NewVacancyViewModel> UpdateVacancy(NewVacancyViewModel viewModel) { return(UpdateVacancy(viewModel, _newVacancyViewModelServerValidator)); }