Example #1
0
        public async Task Then_If_Has_Title_Training_Provider_ShortDescription_And_Descriptions_Then_Completed(
            string title,
            string programmeId,
            string description,
            string shortDescription,
            string trainingDescription,
            string outcomeDescription,
            string accountLegalEntityPublicHashedId,
            Vacancies.Client.Domain.Entities.TrainingProvider provider,
            ApprenticeshipProgramme programme,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            DisplayVacancyViewModelMapper mapper)
        {
            recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programmeId)).ReturnsAsync(programme);
            var vacancy = new Vacancy
            {
                Id                  = Guid.NewGuid(),
                Title               = title,
                ProgrammeId         = programmeId,
                Description         = description,
                TrainingDescription = trainingDescription,
                ShortDescription    = shortDescription,
                OutcomeDescription  = outcomeDescription,
                TrainingProvider    = provider,
                AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId
            };
            var model = new VacancyPreviewViewModel();
            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed);
        }
Example #2
0
        public async Task Then_If_Has_Title_Training_Provider_ShortDescription_Then_In_Progress(
            string title,
            string programmeId,
            string shortDescription,
            Vacancies.Client.Domain.Entities.TrainingProvider provider,
            ApprenticeshipProgramme programme,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            DisplayVacancyViewModelMapper mapper)
        {
            recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programmeId)).ReturnsAsync(programme);
            var vacancy = new Vacancy
            {
                Id               = Guid.NewGuid(),
                Title            = title,
                ProgrammeId      = programmeId,
                ShortDescription = shortDescription,
                TrainingProvider = provider
            };
            var model = new VacancyPreviewViewModel();
            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.InProgress);
        }
        public async Task Then_The_Section_State_Is_Set_to_Not_Started(
            string title,
            string programmeId,
            string description,
            string shortDescription,
            string trainingDescription,
            string outcomeDescription,
            string accountLegalEntityPublicHashedId,
            Vacancies.Client.Domain.Entities.TrainingProvider provider,
            ApprenticeshipProgramme programme,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            DisplayVacancyViewModelMapper mapper)
        {
            var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy();

            vacancy.NumberOfPositions = null;
            var model = new VacancyPreviewViewModel();

            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed);
            model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.InProgress);
            model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.NotStarted);
        }
        public async Task Then_If_There_Are_Skills_Qualifications_And_Other_Things_To_Consider_Added_Section_Set_To_Complete(
            string title,
            string programmeId,
            string description,
            string shortDescription,
            string trainingDescription,
            string outcomeDescription,
            List <string> skills,
            string otherThingsToConsider,
            List <Qualification> qualifications,
            Vacancies.Client.Domain.Entities.TrainingProvider provider,
            ApprenticeshipProgramme programme,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            DisplayVacancyViewModelMapper mapper)
        {
            var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy();

            vacancy.Skills           = skills;
            vacancy.Qualifications   = qualifications;
            vacancy.ThingsToConsider = otherThingsToConsider;
            var model = new VacancyPreviewViewModel();

            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.Completed);
        }
Example #5
0
        public async Task Then_The_Vacancy_Is_Retrieved_And_Mapped(
            string findAnApprenticeshipUrl,
            VacancyRouteModel routeModel,
            ApprenticeshipProgramme programme,
            Vacancy vacancy,
            List <LegalEntity> legalEntities,
            [Frozen] Mock <IOptions <ExternalLinksConfiguration> > externalLinksConfiguration,
            [Frozen] Mock <IUtility> utility,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            [Frozen] Mock <IEmployerVacancyClient> employerVacancyClient,
            VacancyTaskListOrchestrator orchestrator)
        {
            vacancy.EmployerLocation   = null;
            vacancy.EmployerNameOption = EmployerNameOption.RegisteredName;
            programme.Id = vacancy.ProgrammeId;
            programme.EducationLevelNumber = 3;
            programme.ApprenticeshipLevel  = ApprenticeshipLevel.Higher;
            employerVacancyClient.Setup(x => x.GetEmployerLegalEntitiesAsync(routeModel.EmployerAccountId))
            .ReturnsAsync(legalEntities);
            utility.Setup(x => x.GetAuthorisedVacancyForEditAsync(It.Is <VacancyRouteModel>(
                                                                      c => c.VacancyId.Equals(routeModel.VacancyId) &&
                                                                      c.EmployerAccountId.Equals(routeModel.EmployerAccountId)), RouteNames.EmployerTaskListGet))
            .ReturnsAsync(vacancy);
            recruitVacancyClient.Setup(x => x.GetActiveApprenticeshipProgrammesAsync())
            .ReturnsAsync(new List <ApprenticeshipProgramme> {
                programme
            });
            recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programme.Id))
            .ReturnsAsync(programme);
            recruitVacancyClient.Setup(x => x.GetEmployerDescriptionAsync(vacancy)).ReturnsAsync(vacancy.EmployerDescription);
            recruitVacancyClient.Setup(x => x.GetEmployerNameAsync(vacancy)).ReturnsAsync(vacancy.EmployerName);
            externalLinksConfiguration.Object.Value.FindAnApprenticeshipUrl = findAnApprenticeshipUrl;
            var expectedViewModel = new VacancyPreviewViewModel();
            var mapper            = new DisplayVacancyViewModelMapper(Mock.Of <IGeocodeImageService>(),
                                                                      externalLinksConfiguration.Object, recruitVacancyClient.Object);

            var viewModel = await orchestrator.GetVacancyTaskListModel(routeModel);

            await mapper.MapFromVacancyAsync(expectedViewModel, vacancy);

            viewModel.Should().BeEquivalentTo(expectedViewModel, options => options
                                              .Excluding(c => c.SoftValidationErrors)
                                              .Excluding(c => c.RejectedReason)
                                              .Excluding(c => c.HasProgramme)
                                              .Excluding(c => c.HasWage)
                                              .Excluding(c => c.CanShowReference)
                                              .Excluding(c => c.CanShowDraftHeader)
                                              .Excluding(c => c.EducationLevelName)
                                              .Excluding(c => c.ApprenticeshipLevel)
                                              .Excluding(c => c.AccountLegalEntityCount)
                                              .Excluding(c => c.HasSelectedEmployerNameOption)
                                              );
            viewModel.ApprenticeshipLevel.Should().Be(programme.ApprenticeshipLevel);
            viewModel.AccountLegalEntityCount.Should().Be(legalEntities.Count);
            viewModel.HasSelectedEmployerNameOption.Should().BeTrue();
        }
Example #6
0
        public static T ToVacancyProjectionBase <T>(this Vacancy vacancy, ApprenticeshipProgramme programme, Func <string> getDocumentId, ITimeProvider timeProvider) where T : VacancyProjectionBase
        {
            var projectedVacancy = (T)Activator.CreateInstance <T>();

            projectedVacancy.Id                      = getDocumentId();
            projectedVacancy.LastUpdated             = timeProvider.Now;
            projectedVacancy.VacancyId               = vacancy.Id;
            projectedVacancy.ApplicationInstructions = vacancy.ApplicationInstructions;
            projectedVacancy.ApplicationMethod       = vacancy.ApplicationMethod.GetValueOrDefault().ToString();
            projectedVacancy.ApplicationUrl          = vacancy.ApplicationUrl;
            projectedVacancy.ClosingDate             = vacancy.ClosingDate.GetValueOrDefault();
            projectedVacancy.Description             = vacancy.Description;
            projectedVacancy.DisabilityConfident     = vacancy.DisabilityConfident;
            projectedVacancy.EmployerContactEmail    = vacancy.EmployerContact?.Email;
            projectedVacancy.EmployerContactName     = vacancy.EmployerContact?.Name;
            projectedVacancy.EmployerContactPhone    = vacancy.EmployerContact?.Phone;
            projectedVacancy.ProviderContactEmail    = vacancy.ProviderContact?.Email;
            projectedVacancy.ProviderContactName     = vacancy.ProviderContact?.Name;
            projectedVacancy.ProviderContactPhone    = vacancy.ProviderContact?.Phone;
            projectedVacancy.EmployerDescription     = vacancy.EmployerDescription;
            projectedVacancy.EmployerLocation        = vacancy.EmployerLocation.ToProjection(vacancy.IsAnonymous);
            projectedVacancy.EmployerName            = vacancy.EmployerName;
            projectedVacancy.EmployerWebsiteUrl      = vacancy.IsAnonymous ? null : vacancy.EmployerWebsiteUrl;
            projectedVacancy.IsAnonymous             = vacancy.IsAnonymous;
            projectedVacancy.LiveDate                = vacancy.LiveDate.GetValueOrDefault();
            projectedVacancy.NumberOfPositions       = vacancy.NumberOfPositions.GetValueOrDefault();
            projectedVacancy.OutcomeDescription      = vacancy.OutcomeDescription;
            projectedVacancy.ProgrammeId             = vacancy.ProgrammeId;
            projectedVacancy.ProgrammeLevel          = programme.ApprenticeshipLevel.ToString();
            projectedVacancy.ProgrammeType           = programme.ApprenticeshipType.ToString();
            projectedVacancy.Qualifications          = vacancy.Qualifications.ToProjection();
            projectedVacancy.ShortDescription        = vacancy.ShortDescription;
            projectedVacancy.Skills                  = vacancy.Skills;
            projectedVacancy.StartDate               = vacancy.StartDate.GetValueOrDefault();
            projectedVacancy.ThingsToConsider        = vacancy.ThingsToConsider;
            projectedVacancy.Title                   = vacancy.Title;
            projectedVacancy.TrainingDescription     = vacancy.TrainingDescription;
            projectedVacancy.TrainingProvider        = vacancy.TrainingProvider.ToProjection();
            projectedVacancy.VacancyReference        = vacancy.VacancyReference.GetValueOrDefault();
            projectedVacancy.Wage                    = vacancy.Wage.ToProjection();
            projectedVacancy.EducationLevelNumber    = programme.EducationLevelNumber;

            projectedVacancy.AccountPublicHashedId            = vacancy.EmployerAccountId;
            projectedVacancy.AccountLegalEntityPublicHashedId = vacancy.AccountLegalEntityPublicHashedId;

            return(projectedVacancy);
        }
        public async Task Then_If_There_Section_Two_Is_Completed_Then_Section_Three_Set_To_NotStarted(
            string title,
            string programmeId,
            string description,
            string shortDescription,
            string trainingDescription,
            string outcomeDescription,
            List <string> skills,
            Vacancies.Client.Domain.Entities.TrainingProvider provider,
            ApprenticeshipProgramme programme,
            [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient,
            DisplayVacancyViewModelMapper mapper)
        {
            var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy();
            var model   = new VacancyPreviewViewModel();

            await mapper.MapFromVacancyAsync(model, vacancy);

            model.SetSectionStates(model, new ModelStateDictionary());

            model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed);
            model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.Completed);
            model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.NotStarted);
        }