Exemple #1
0
        public async Task Then_Each_Apprentice_Record_Is_Checked_And_If_Client_Returns_Ok_Is_Returned(
            List <ApprenticeshipItem> allApprenticeship,
            ApprenticeshipItem passingApprenticeship,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            ApprenticeshipService service)
        {
            //Arrange
            client.Setup(x => x.GetResponseCode(It.IsAny <IGetApiRequest>()))
            .ReturnsAsync(HttpStatusCode.NotFound);

            allApprenticeship.Add(passingApprenticeship);
            client.Setup(x =>
                         x.GetResponseCode(It.Is <GetEligibleApprenticeshipsRequest>(c =>
                                                                                     c.GetUrl.Contains($@"/{passingApprenticeship.Uln}?") &&
                                                                                     c.GetUrl.Contains($@"?startDate={passingApprenticeship.StartDate:yyyy-MM-dd}&isApproved")
                                                                                     )))
            .ReturnsAsync(HttpStatusCode.OK);

            //Act
            var actual = await service.GetEligibleApprenticeships(allApprenticeship);

            //Assert
            actual.ToList().Should().ContainEquivalentOf(passingApprenticeship);
            actual.Length.Should().Be(1);
        }
Exemple #2
0
        public void Then_The_Fields_Are_Correctly_Mapped(ApprenticeshipItem source)
        {
            var actual = (EligibleApprenticeshipDto)source;

            actual.ApprenticeshipId.Should().Be(source.Id);
            actual.CourseName.Should().Be(source.CourseName);
            actual.FirstName.Should().Be(source.FirstName);
            actual.LastName.Should().Be(source.LastName);
            actual.Uln.Should().Be(source.Uln);
        }
Exemple #3
0
        public void Then_An_Exception_Is_Thrown_If_The_Uln_Is_Not_Found(
            List <ApprenticeshipItem> allApprenticeship,
            ApprenticeshipItem passingApprenticeship,
            [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client,
            ApprenticeshipService service)
        {
            //Arrange
            client.Setup(x =>
                         x.GetResponseCode(It.IsAny <GetEligibleApprenticeshipsRequest>()))
            .ReturnsAsync(HttpStatusCode.InternalServerError);

            //Act
            Assert.ThrowsAsync <ApplicationException>(() => service.GetEligibleApprenticeships(allApprenticeship));
        }
Exemple #4
0
        private async Task VerifyApprenticeshipIsEligible(ApprenticeshipItem apprenticeship, ConcurrentBag <ApprenticeshipItem> bag)
        {
            var statusCode = await _client.GetResponseCode(new GetEligibleApprenticeshipsRequest(apprenticeship.Uln, apprenticeship.StartDate));

            switch (statusCode)
            {
            case HttpStatusCode.OK:
                bag.Add(apprenticeship);
                break;

            case HttpStatusCode.NotFound:
                break;

            default:
                throw new ApplicationException($"Unable to get status for apprentice Uln {apprenticeship.Uln}");
            }
        }
        public void GivenThisSearchRequestFindsSeveralApprovedApprenticeships()
        {
            SetupIncentiveDetailsResponse();

            _eligibleApprenticeship1    = _fixture.Create <ApprenticeshipItem>();
            _eligibleApprenticeship2    = _fixture.Create <ApprenticeshipItem>();
            _nonEligibleApprenticeship3 = _fixture.Create <ApprenticeshipItem>();
            _nonEligibleApprenticeship4 = _fixture.Create <ApprenticeshipItem>();
            _nonEligibleApprenticeship5 = _fixture.Create <ApprenticeshipItem>();

            var response = new ApprenticeshipSearchResponse
            {
                Apprenticeships = new ApprenticeshipItem[]
                {
                    _eligibleApprenticeship1, _eligibleApprenticeship2, _nonEligibleApprenticeship3,
                    _nonEligibleApprenticeship4, _nonEligibleApprenticeship5
                }
            };

            SetApprenticeshipSearchToReturn(response);
        }
        public void GivenThisSearchRequestFindsSeveralApprovedApprenticeshipsWhichAreStopped()
        {
            SetupIncentiveDetailsResponse();

            _eligibleApprenticeship1    = _fixture.Build <ApprenticeshipItem>().With(a => a.ApprenticeshipStatus, ApprenticeshipStatus.Stopped).Create();
            _eligibleApprenticeship2    = _fixture.Build <ApprenticeshipItem>().With(a => a.ApprenticeshipStatus, ApprenticeshipStatus.Stopped).Create();
            _nonEligibleApprenticeship3 = _fixture.Build <ApprenticeshipItem>().With(a => a.ApprenticeshipStatus, ApprenticeshipStatus.Stopped).Create();
            _nonEligibleApprenticeship4 = _fixture.Build <ApprenticeshipItem>().With(a => a.ApprenticeshipStatus, ApprenticeshipStatus.Stopped).Create();
            _nonEligibleApprenticeship5 = _fixture.Build <ApprenticeshipItem>().With(a => a.ApprenticeshipStatus, ApprenticeshipStatus.Stopped).Create();

            var response = new ApprenticeshipSearchResponse
            {
                Apprenticeships = new ApprenticeshipItem[]
                {
                    _eligibleApprenticeship1, _eligibleApprenticeship2, _nonEligibleApprenticeship3,
                    _nonEligibleApprenticeship4, _nonEligibleApprenticeship5
                }
            };

            SetApprenticeshipSearchToReturn(response);
        }