public async Task And_Application_Exists_Stitches_Up_Standard_To_Result(
            GetApplicationQuery getApplicationQuery,
            GetApplicationResponse getApplicationResponse,
            GetStandardsListItem getStandardsListItem,
            GetCohortsResponse getCohortsResponse,
            [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > mockCoursesApiClient,
            [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService,
            [Frozen] Mock <ICommitmentsV2ApiClient <CommitmentsV2ApiConfiguration> > mockCommitmentsV2ApiClient,
            GetApplicationQueryHandler getApplicationQueryHandler)
        {
            mockLevyTransferMatchingService
            .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getApplicationQuery.ApplicationId.ToString()))))
            .ReturnsAsync(getApplicationResponse);

            mockCoursesApiClient
            .Setup(x => x.Get <GetStandardsListItem>(It.Is <GetStandardDetailsByIdRequest>(y => y.GetUrl.Contains(getApplicationResponse.StandardId))))
            .ReturnsAsync(getStandardsListItem);

            mockCommitmentsV2ApiClient
            .Setup(x => x.Get <GetCohortsResponse>(It.Is <GetCohortsRequest>(y => y.GetUrl.Contains(getApplicationQuery.AccountId.ToString()))))
            .ReturnsAsync(getCohortsResponse);

            var result = await getApplicationQueryHandler.Handle(getApplicationQuery, CancellationToken.None);

            Assert.IsNotNull(result);
            Assert.AreEqual(getApplicationResponse.Status, result.Status);
        }
        public async Task Then_data_is_fetched_via_data_repository()
        {
            //Arrange
            var query          = _fixture.Create <GetApplicationRequest>();
            var apprenticeship = _fixture.Build <IncentiveApplicationApprenticeshipDto>().With(x => x.PlannedStartDate, new DateTime(2020, 9, 1)).Create();
            var data           = _fixture.Build <IncentiveApplicationDto>().With(x => x.Apprenticeships, new List <IncentiveApplicationApprenticeshipDto> {
                apprenticeship
            }).Create();
            var expected    = new GetApplicationResponse(data);
            var legalEntity = _fixture.Create <LegalEntityDto>();

            _applicationRepository.Setup(x => x.Get(dto => dto.Id == query.ApplicationId && dto.AccountId == query.AccountId)).ReturnsAsync(data);
            _legalEntityRepository.Setup(x => x.Get(y => y.AccountLegalEntityId == data.AccountLegalEntityId)).ReturnsAsync(legalEntity);

            //Act
            var result = await _sut.Handle(query, CancellationToken.None);

            //Assert
            result.Should().BeEquivalentTo(expected, opts => opts.Excluding(x => x.Application.NewAgreementRequired));
        }
        public async Task And_Application_Doesnt_Exist_Returns_Null(
            GetApplicationQuery getApplicationQuery,
            [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService,
            GetApplicationQueryHandler getApplicationQueryHandler)
        {
            mockLevyTransferMatchingService
            .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getApplicationQuery.ApplicationId.ToString()))))
            .ReturnsAsync((GetApplicationResponse)null);

            var result = await getApplicationQueryHandler.Handle(getApplicationQuery, CancellationToken.None);

            Assert.IsNull(result);
        }
        public async Task And_Application_Exists_And_No_Specific_Locations_Returned_Stitches_Up_Standard_And_Location_To_Result(
            GetApplicationQuery getApplicationQuery,
            GetApplicationResponse getApplicationResponse,
            [Frozen] Mock <ILevyTransferMatchingService> mockLevyTransferMatchingService,
            GetApplicationQueryHandler getApplicationQueryHandler)
        {
            mockLevyTransferMatchingService
            .Setup(x => x.GetApplication(It.Is <GetApplicationRequest>(y => y.GetUrl.Contains(getApplicationQuery.PledgeId.ToString()) && y.GetUrl.Contains(getApplicationQuery.ApplicationId.ToString()))))
            .ReturnsAsync(getApplicationResponse);

            var result = await getApplicationQueryHandler.Handle(getApplicationQuery, CancellationToken.None);

            Assert.IsNotNull(result);
            Assert.AreEqual(getApplicationResponse.Details, result.AboutOpportunity);
        }