Exemple #1
0
        public ApprenticeCommitmentsInnerApiBuilder(int port)
        {
            _fixture = new Fixture();
            _server  = WireMockServer.StartWithAdminInterface(port, true);

            _registrationsInNeedOfReminders = _fixture.CreateMany <RegistrationsRemindersInvitationsResponse.Registration>();
            _existingApprenticship          = _fixture.Create <ApprenticeshipResponse>();
        }
 public GetApprenticeshipSteps(TestContext context)
 {
     _context          = context;
     _apprenticeId     = _fixture.Create <Guid>();
     _apprenticeshipId = _fixture.Create <int>();
     _apprenticeship   = _fixture.Build <ApprenticeshipResponse>()
                         .With(x => x.Id, _apprenticeshipId)
                         .Create();
 }
        public void Then_The_Fields_Are_Correctly_Mapped(ApprenticeshipResponse source)
        {
            var actual = (IncentiveClaimApprenticeshipDto)source;

            actual.ApprenticeshipId.Should().Be(source.Id);
            actual.FirstName.Should().Be(source.FirstName);
            actual.LastName.Should().Be(source.LastName);
            actual.Uln.Should().Be(source.Uln);
            actual.DateOfBirth.Should().Be(source.DateOfBirth);
            actual.ApprenticeshipEmployerTypeOnApproval.Should().Be(source.ApprenticeshipEmployerTypeOnApproval);
            actual.UKPRN.Should().Be(source.ProviderId);
        }
        public void And_We_Find_Matching_Apprenticeships_With_Different_AccountIds_Then_Throws_UnauthorizedAccessException(
            long accountId,
            long[] apprenticeshipIds,
            ApprenticeshipResponse apprenticeshipDetail,
            [Frozen] Mock <ICommitmentsApiClient <CommitmentsConfiguration> > client,
            [Greedy] CommitmentsService sut)
        {
            client.Setup(x => x.Get <ApprenticeshipResponse>(It.IsAny <IGetApiRequest>()))
            .ReturnsAsync(apprenticeshipDetail);

            Assert.ThrowsAsync <UnauthorizedAccessException>(() => sut.GetApprenticeshipDetails(accountId, apprenticeshipIds));
        }
        public async Task Then_The_Service_Is_Called_With_The_Request_To_Confirm_Employment_Details()
        {
            var fixture = new Fixture();

            var request = new ApprenticeshipDetailsRequest
            {
                AccountId             = fixture.Create <long>(),
                ApplicationId         = Guid.NewGuid(),
                ApprenticeshipDetails = new List <ApprenticeDetailsDto>()
            };

            request.ApprenticeshipDetails.Add(new ApprenticeDetailsDto {
                ApprenticeId = fixture.Create <long>(), EmploymentStartDate = fixture.Create <DateTime>()
            });
            request.ApprenticeshipDetails.Add(new ApprenticeDetailsDto {
                ApprenticeId = fixture.Create <long>(), EmploymentStartDate = fixture.Create <DateTime>()
            });
            request.ApprenticeshipDetails.Add(new ApprenticeDetailsDto {
                ApprenticeId = fixture.Create <long>(), EmploymentStartDate = fixture.Create <DateTime>()
            });
            var apprenticeIds = request.ApprenticeshipDetails.Select(x => x.ApprenticeId).ToList();

            var command = new SaveApprenticeshipDetailsCommand(request);

            var commitmentsService        = new Mock <ICommitmentsService>();
            var commitmentApprenticeships = new List <ApprenticeshipResponse>();

            foreach (var apprenticeId in apprenticeIds)
            {
                var commitment = new ApprenticeshipResponse {
                    Id = apprenticeId, EmployerAccountId = request.AccountId, Uln = fixture.Create <long>()
                };
                commitmentApprenticeships.Add(commitment);
            }
            commitmentsService.Setup(x => x.GetApprenticeshipDetails(request.AccountId, apprenticeIds)).ReturnsAsync(commitmentApprenticeships.ToArray());

            var applicationService = new Mock <IApplicationService>();
            var handler            = new SaveApprenticeshipDetailsCommandHandler(commitmentsService.Object, applicationService.Object);

            await handler.Handle(command, CancellationToken.None);

            commitmentsService.Verify(x => x.GetApprenticeshipDetails(
                                          It.Is <long>(r => r == command.ApprenticeshipDetailsRequest.AccountId),
                                          It.IsAny <IEnumerable <long> >()), Times.Once);

            applicationService.Verify(x => x.Update(
                                          It.Is <UpdateIncentiveApplicationRequestData>(
                                              r =>
                                              r.AccountId == command.ApprenticeshipDetailsRequest.AccountId &&
                                              r.IncentiveApplicationId == command.ApprenticeshipDetailsRequest.ApplicationId)),
                                      Times.Once);
        }
 private void SetResponseFromCommitmentsForApprenticeshipId(long id, ApprenticeshipResponse response)
 {
     _context.CommitmentsV2InnerApi.MockServer
     .Given(
         Request.Create().WithPath($"/api/apprenticeships/{id}")
         .UsingGet())
     .RespondWith(
         Response.Create()
         .WithStatusCode((int)HttpStatusCode.OK)
         .WithHeader("Content-Type", "application/json")
         .WithBody(JsonSerializer.Serialize(response))
         );
 }
Exemple #7
0
 public GetApprenticeshipsSteps(TestContext context)
 {
     _context        = context;
     _apprenticeId   = _fixture.Create <Guid>();
     _apprenticeship = _fixture.Create <ApprenticeshipResponse>();
 }