示例#1
0
        public void ShouldUpdateWage()
        {
            //Arrange.
            const int vacancyReferenceNumber = 1;
            var       closingDate            = DateTime.Today.AddDays(20);
            var       possibleStartDate      = DateTime.Today.AddDays(30);

            var wageViewModel = new WageViewModel()
            {
                Type             = WageType.Custom,
                CustomType       = CustomWageType.Fixed,
                Amount           = 450,
                AmountLowerBound = null,
                AmountUpperBound = null,
                Text             = null,
                Unit             = WageUnit.Monthly,
                HoursPerWeek     = 37.5m
            };
            var wage = new Wage(WageType.Custom, 450, null, null, null, WageUnit.Monthly, 37.5m, null);

            var updatedViewModel = new FurtherVacancyDetailsViewModel
            {
                VacancyDatesViewModel = new VacancyDatesViewModel
                {
                    ClosingDate       = new DateViewModel(closingDate),
                    PossibleStartDate = new DateViewModel(possibleStartDate)
                },
                VacancyReferenceNumber = vacancyReferenceNumber,
                Wage = wageViewModel
            };

            var dbApprenticeshipVacancy = new Vacancy
            {
                VacancyReferenceNumber = vacancyReferenceNumber,
                Wage = new Wage(WageType.NationalMinimum, null, null, null, "Legacy text", WageUnit.Weekly, 30, null)
            };

            MockVacancyPostingService.Setup(s => s.GetVacancyByReferenceNumber(vacancyReferenceNumber))
            .Returns(dbApprenticeshipVacancy);
            MockVacancyPostingService.Setup(s => s.UpdateVacancy(It.IsAny <Vacancy>()))
            .Returns(dbApprenticeshipVacancy);
            MockMapper.Setup(m => m.Map <WageViewModel, Wage>(It.IsAny <WageViewModel>())).Returns(wage);
            MockMapper.Setup(m => m.Map <Wage, WageViewModel>(It.IsAny <Wage>())).Returns(wageViewModel); //this line kind of invalidates this test.
            MockMapper.Setup(m => m.Map <Vacancy, FurtherVacancyDetailsViewModel>(dbApprenticeshipVacancy))
            .Returns(updatedViewModel);

            var provider = GetVacancyPostingProvider();

            //Act.
            provider.UpdateVacancyDates(updatedViewModel);

            //Assert.
            MockVacancyPostingService.Verify(s => s.UpdateVacancy(It.Is <Vacancy>(
                                                                      v => v.PossibleStartDate == possibleStartDate &&
                                                                      v.Wage.Type == updatedViewModel.Wage.Type &&
                                                                      v.Wage.Amount == updatedViewModel.Wage.Amount &&
                                                                      v.Wage.Text == dbApprenticeshipVacancy.Wage.Text &&
                                                                      v.Wage.Unit == updatedViewModel.Wage.Unit &&
                                                                      v.Wage.HoursPerWeek == dbApprenticeshipVacancy.Wage.HoursPerWeek)));
        }
示例#2
0
        public async Task <WageViewModel> GetWageViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Wage_Get);

            var wagePeriod = _minimumWageProvider.GetWagePeriod(vacancy.StartDate.Value);

            var vm = new WageViewModel
            {
                WageType = vacancy.Wage?.WageType,
                FixedWageYearlyAmount               = vacancy.Wage?.FixedWageYearlyAmount?.AsMoney(),
                WageAdditionalInformation           = vacancy.Wage?.WageAdditionalInformation,
                MinimumWageStartFrom                = wagePeriod.ValidFrom.ToMonthNameYearString(),
                NationalMinimumWageLowerBoundHourly = wagePeriod.NationalMinimumWageLowerBound.ToString("C"),
                NationalMinimumWageUpperBoundHourly = wagePeriod.NationalMinimumWageUpperBound.ToString("C"),
                NationalMinimumWageYearly           = GetMinimumWageYearlyText(SFA.DAS.VacancyServices.Wage.WageType.NationalMinimum, vacancy.Wage?.WeeklyHours, vacancy.StartDate.Value),
                ApprenticeshipMinimumWageHourly     = wagePeriod.ApprenticeshipMinimumWage.ToString("C"),
                ApprenticeshipMinimumWageYearly     = GetMinimumWageYearlyText(SFA.DAS.VacancyServices.Wage.WageType.ApprenticeshipMinimum, vacancy.Wage?.WeeklyHours, vacancy.StartDate.Value),
                WeeklyHours = vacancy.Wage.WeeklyHours.Value,
                PageInfo    = Utility.GetPartOnePageInfo(vacancy)
            };

            if (vacancy.Status == VacancyStatus.Referred)
            {
                vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
                                                                                       ReviewFieldMappingLookups.GetWageReviewFieldIndicators());
            }

            return(vm);
        }
 public void SetUp()
 {
     _serverCommonValidator = new VacancyDatesViewModelServerCommonValidator();
     _serverValidator       = new VacancyDatesViewModelServerValidator();
     _commonValidator       = new VacancyDatesViewModelCommonValidator();
     _vacancyValidator      = new VacancyViewModelValidator();
     _wageViewModel         = new WageViewModel();
 }
示例#4
0
 public void SetUp()
 {
     _commonValidator        = new VacancyDatesViewModelCommonValidator();
     _serverCommonValidator  = new VacancyDatesViewModelServerCommonValidator();
     _serverWarningValidator = new VacancyDatesViewModelServerWarningValidator(null);
     _aggregateValidator     = new VacancyViewModelValidator();
     _wageViewModel          = new WageViewModel();
 }
示例#5
0
        public async Task <WageViewModel> GetWageViewModelAsync(VacancyRouteModel vrm)
        {
            var vacancy = await Utility.GetAuthorisedVacancyForEditAsync(_client, _vacancyClient, vrm, RouteNames.Wage_Get);

            var vm = new WageViewModel
            {
                Duration                  = vacancy.Wage?.Duration?.ToString(),
                DurationUnit              = vacancy.Wage?.DurationUnit ?? DurationUnit.Year,
                WorkingWeekDescription    = vacancy.Wage?.WorkingWeekDescription,
                WeeklyHours               = $"{vacancy.Wage?.WeeklyHours:0.##}",
                WageType                  = vacancy.Wage?.WageType,
                FixedWageYearlyAmount     = vacancy.Wage?.FixedWageYearlyAmount?.AsMoney(),
                WageAdditionalInformation = vacancy.Wage?.WageAdditionalInformation,
                PageInfo                  = Utility.GetPartOnePageInfo(vacancy)
            };

            if (vacancy.Status == VacancyStatus.Referred)
            {
                vm.Review = await _reviewSummaryService.GetReviewSummaryViewModelAsync(vacancy.VacancyReference.Value,
                                                                                       ReviewFieldMappingLookups.GetWageReviewFieldIndicators());
            }

            return(vm);
        }
示例#6
0
 public VacancyViewModelBuilder With(WageViewModel wageObject)
 {
     _wageViewModel = wageObject;
     _furtherVacancyDetailsViewModel.Wage = wageObject;
     return(this);
 }
        public void ShouldReturnOKIfTheUserCanLockTheVacancy()
        {
            //Arrange
            const string ukprn = "ukprn";
            //const int QAVacancyTimeout = 10;
            const string userName = "******";
            var          utcNow   = DateTime.UtcNow;
            const int    vacancyReferenceNumber = 1;
            const string aString = "aString";
            const int    autoSaveTimeoutInSeconds = 60;

            var sectorList = new List <Sector>
            {
                new Fixture().Build <Sector>().Create()
            };

            var wage = new WageViewModel()
            {
                CustomType       = CustomWageType.Fixed,
                Amount           = null,
                AmountLowerBound = null,
                AmountUpperBound = null,
                Text             = null,
                Unit             = WageUnit.NotApplicable,
                HoursPerWeek     = null
            };
            var viewModel = new FurtherVacancyDetailsViewModel
            {
                DurationComment       = aString,
                VacancyDatesViewModel = new VacancyDatesViewModel
                {
                    PossibleStartDate = new DateViewModel(),
                    ClosingDate       = new DateViewModel()
                },
                VacancyReferenceNumber   = vacancyReferenceNumber,
                AutoSaveTimeoutInSeconds = autoSaveTimeoutInSeconds,
                Wage = wage
            };

            var vacancy = new Fixture().Build <Vacancy>()
                          .With(av => av.VacancyReferenceNumber, vacancyReferenceNumber)
                          .With(av => av.DurationComment, aString)
                          .Create();

            var configurationService = new Mock <IConfigurationService>();

            configurationService.Setup(x => x.Get <CommonWebConfiguration>())
            .Returns(new CommonWebConfiguration {
                BlacklistedCategoryCodes = ""
            });
            configurationService.Setup(x => x.Get <RecruitWebConfiguration>())
            .Returns(new RecruitWebConfiguration {
                AutoSaveTimeoutInSeconds = autoSaveTimeoutInSeconds
            });
            var referenceDataService = new Mock <IReferenceDataService>();

            referenceDataService.Setup(m => m.GetSectors()).Returns(sectorList);
            var providerService = new Mock <IProviderService>();

            providerService.Setup(ps => ps.GetProvider(ukprn, true)).Returns(new Provider());

            var vacancyPostingService = new Mock <IVacancyPostingService>();
            var currentUserService    = new Mock <ICurrentUserService>();

            currentUserService.Setup(cus => cus.CurrentUserName).Returns(userName);
            var dateTimeService = new Mock <IDateTimeService>();

            dateTimeService.Setup(dts => dts.UtcNow).Returns(utcNow);
            var vacancylockingService = new Mock <IVacancyLockingService>();

            vacancylockingService.Setup(vls => vls.IsVacancyAvailableToQABy(userName, vacancy)).Returns(true);

            //Arrange: get AV, update retrieved AV with NVVM, save modified AV returning same modified AV, map AV to new NVVM with same properties as input
            vacancyPostingService.Setup(
                vps => vps.GetVacancyByReferenceNumber(vacancyReferenceNumber)).Returns(vacancy);

            vacancyPostingService.Setup(vps => vps.UpdateVacancy(It.IsAny <Vacancy>())).Returns((Vacancy av) => av);

            var mapper = new Mock <IMapper>();

            mapper.Setup(m => m.Map <Wage, WageViewModel>(It.IsAny <Wage>())).Returns(wage);
            mapper.Setup(m => m.Map <Vacancy, FurtherVacancyDetailsViewModel>(It.IsAny <Vacancy>()))
            .Returns((Vacancy av) => viewModel);

            var vacancyProvider =
                new VacancyProviderBuilder().With(vacancyPostingService)
                .With(providerService)
                .With(configurationService)
                .With(referenceDataService)
                .With(mapper)
                .With(currentUserService)
                .With(dateTimeService)
                .With(vacancylockingService)
                .Build();

            //Act
            var result = vacancyProvider.UpdateVacancyWithComments(viewModel);

            //Assert
            vacancyPostingService.Verify(
                vps => vps.GetVacancyByReferenceNumber(viewModel.VacancyReferenceNumber), Times.Once);
            vacancyPostingService.Verify(
                vps =>
                vps.UpdateVacancy(
                    It.Is <Vacancy>(av => av.VacancyReferenceNumber == viewModel.VacancyReferenceNumber &&
                                    av.QAUserName == userName && av.DateStartedToQA == utcNow)));
            result.Code.Should().Be(QAActionResultCode.Ok);
        }