public void SetUp()
        {
            _getAccountResponse  = _fixture.Create <GetAccountResponse>();
            _command             = _fixture.Create <CreateApplicationCommand>();
            _response            = _fixture.Create <CreateApplicationResponse>();
            _getStandardResponse = _fixture.Create <GetStandardsListItem>();

            _account         = _fixture.Create <Account>();
            _accountsService = new Mock <IAccountsService>();
            _accountsService.Setup(x => x.GetAccount(_command.EncodedAccountId)).ReturnsAsync(_account);

            _coursesApiClient = new Mock <ICoursesApiClient <CoursesApiConfiguration> >();
            _coursesApiClient.Setup(x => x.Get <GetStandardsListItem>(It.Is <GetStandardDetailsByIdRequest>(r => r.Id == _command.StandardId)))
            .ReturnsAsync(_getStandardResponse);

            _levyTransferMatchingService = new Mock <ILevyTransferMatchingService>();

            _levyTransferMatchingService.Setup(x => x.GetAccount(It.Is <GetAccountRequest>(r => r.AccountId == _command.EmployerAccountId)))
            .ReturnsAsync(_getAccountResponse);

            _levyTransferMatchingService.Setup(x => x.CreateApplication(It.IsAny <CreateApplicationRequest>()))
            .Callback <CreateApplicationRequest>(r => _createApplicationRequest = r)
            .ReturnsAsync(_response);

            _handler = new CreateApplicationCommandHandler(_levyTransferMatchingService.Object, _accountsService.Object, Mock.Of <ILogger <CreateApplicationCommandHandler> >(), _coursesApiClient.Object);
        }
Esempio n. 2
0
        public async Task Then_The_CommitmentService_Is_Called_To_Get_Apprenticeship_Details(
            long accountId,
            long accountLegalEntityId,
            long[] apprenticeshipIds,
            Guid applicationId,
            [Frozen] Mock <ICommitmentsService> commitmentsService,
            CreateApplicationCommandHandler handler)
        {
            var command = new CreateApplicationCommand(applicationId, accountId, accountLegalEntityId, apprenticeshipIds);

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

            commitmentsService.Verify(x => x.GetApprenticeshipDetails(command.AccountId, command.ApprenticeshipIds), Times.Once);
        }
Esempio n. 3
0
        public async Task Then_The_EmployerIncentivesService_Is_Called_To_Create_The_Initial_Application(
            long accountId,
            long accountLegalEntityId,
            long[] apprenticeshipIds,
            Guid applicationId,
            ApprenticeshipResponse[] apprenticeshipDetails,
            [Frozen] Mock <IApplicationService> applicationService,
            [Frozen] Mock <ICommitmentsService> commitmentsService,
            CreateApplicationCommandHandler handler)
        {
            var command = new CreateApplicationCommand(applicationId, accountId, accountLegalEntityId, apprenticeshipIds);

            commitmentsService.Setup(x => x.GetApprenticeshipDetails(command.AccountId, command.ApprenticeshipIds))
            .ReturnsAsync(apprenticeshipDetails);

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

            applicationService.Verify(
                x => x.Create(
                    It.Is <CreateIncentiveApplicationRequestData>(p => p.IncentiveApplicationId == command.ApplicationId &&
                                                                  p.AccountId == command.AccountId && p.AccountLegalEntityId == command.AccountLegalEntityId &&
                                                                  p.Apprenticeships.Length == apprenticeshipDetails.Length)),
                Times.Once);
        }
Esempio n. 4
0
 public CreateApplicationCommandHandlerTest()
 {
     _createApplicationCommandHandler = new CreateApplicationCommandHandler(Context);
 }