コード例 #1
0
        public async Task ThenChangeOfRequestPartyRequestIsMapped(GetApprenticeshipResponse mediatorResponse)
        {
            var comparer = ChangeOfRequestArrange(mediatorResponse);

            var response = await _controller.GetApprenticeship(TestProviderId, TestApprenticeshipId) as OkNegotiatedContentResult <Apprenticeship.Apprenticeship>;

            Assert.IsTrue(response.Content.ChangeOfPartyRequests.Count() > 0);
            Assert.AreEqual(response.Content.ChangeOfPartyRequests.Count(), mediatorResponse.Data.ChangeOfPartyRequests.Count());

            foreach (var actaulChangeOfPartyRequest in response.Content.ChangeOfPartyRequests)
            {
                var expectedChangeOfPartyRequest = mediatorResponse.Data.ChangeOfPartyRequests.Where(x => x.Id == actaulChangeOfPartyRequest.Id).First();
                var result = comparer.Compare(expectedChangeOfPartyRequest, actaulChangeOfPartyRequest);
                Assert.IsTrue(result.AreEqual, result.DifferencesString);
            }
        }
        public void SetUp()
        {
            //Arrange
            var autoFixture = new Fixture();

            _request = autoFixture.Build <ApprenticeshipDetailsRequest>()
                       .With(x => x.AccountHashedId, "123")
                       .With(x => x.ApprenticeshipHashedId, "456")
                       .Create();
            _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                      .With(x => x.CourseCode, "ABC")
                                      .With(x => x.DateOfBirth, autoFixture.Create <DateTime>())
                                      .Create();
            _priceEpisodesResponse = autoFixture.Build <GetPriceEpisodesResponse>()
                                     .With(x => x.PriceEpisodes, new List <PriceEpisode> {
                new PriceEpisode {
                    Cost = 1000, ToDate = DateTime.Now.AddMonths(-1)
                }
            })
                                     .Create();
            _apprenticeshipUpdatesResponse = autoFixture.Build <GetApprenticeshipUpdatesResponse>()
                                             .With(x => x.ApprenticeshipUpdates, new List <ApprenticeshipUpdate> {
                new ApprenticeshipUpdate {
                    OriginatingParty = Party.Employer
                }
            })
                                             .Create();
            _dataLocksResponse             = autoFixture.Build <GetDataLocksResponse>().Create();
            _changeOfPartyRequestsResponse = autoFixture.Build <GetChangeOfPartyRequestsResponse>().Create();
            _trainingProgrammeResponse     = autoFixture.Build <GetTrainingProgrammeResponse>().Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeship(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_apprenticeshipResponse);
            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_priceEpisodesResponse);
            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipUpdates(It.IsAny <long>(), It.IsAny <GetApprenticeshipUpdatesRequest>(), CancellationToken.None))
            .ReturnsAsync(_apprenticeshipUpdatesResponse);
            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeshipDatalocksStatus(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_dataLocksResponse);
            _mockCommitmentsApiClient.Setup(c => c.GetChangeOfPartyRequests(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_changeOfPartyRequestsResponse);
            _mockCommitmentsApiClient.Setup(t => t.GetTrainingProgramme(_apprenticeshipResponse.CourseCode, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_trainingProgrammeResponse);
            _mockEncodingService = new Mock <IEncodingService>();
            _mapper = new ApprenticeshipDetailsRequestToViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object, Mock.Of <ILogger <ApprenticeshipDetailsRequestToViewModelMapper> >());
        }
コード例 #3
0
        public void Arrange()
        {
            _fixture = new Fixture();

            _request = _fixture.Create <ChangeOptionRequest>();

            var baseDate    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            var startDate   = baseDate;
            var endDate     = baseDate.AddYears(2);
            var dateOfBirth = baseDate.AddYears(-18);

            _getApprenticeshipResponse = _fixture.Build <GetApprenticeshipResponse>()
                                         .With(x => x.StartDate, startDate)
                                         .With(x => x.EndDate, endDate)
                                         .With(x => x.DateOfBirth, dateOfBirth)
                                         .Create();

            _editViewModel = _fixture.Build <EditApprenticeshipRequestViewModel>()
                             .With(x => x.CourseCode, _getApprenticeshipResponse.CourseCode)
                             .With(x => x.Version, _getApprenticeshipResponse.Version)
                             .With(x => x.StartDate, new MonthYearModel(startDate.ToString("MMyyyy")))
                             .With(x => x.EndDate, new MonthYearModel(endDate.ToString("MMyyyy")))
                             .With(x => x.DateOfBirth, new MonthYearModel(dateOfBirth.ToString("MMyyyy")))
                             .Create();

            _getVersionResponse = _fixture.Create <GetTrainingProgrammeResponse>();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient
            .Setup(c => c.GetTrainingProgrammeVersionByCourseCodeAndVersion(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getVersionResponse);
            _mockCommitmentsApiClient
            .Setup(c => c.GetApprenticeship(_request.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);

            _mockTempDataDictionary = new Mock <ITempDataDictionary>();

            _mockTempDataFactory = new Mock <ITempDataDictionaryFactory>();
            _mockTempDataFactory.Setup(f => f.GetTempData(It.IsAny <HttpContext>()))
            .Returns(_mockTempDataDictionary.Object);

            _mapper = new ChangeOptionViewModelMapper(_mockCommitmentsApiClient.Object,
                                                      Mock.Of <IHttpContextAccessor>(),
                                                      _mockTempDataFactory.Object);
        }
        public void Arrange()
        {
            var _autoFixture = new Fixture();

            _request = _autoFixture.Build <ChangeOfProviderRequest>()
                       .With(x => x.NewStartMonth, 1)
                       .With(x => x.NewStartYear, 2020)
                       .With(x => x.NewEndMonth, 1)
                       .With(x => x.NewEndYear, 2022)
                       .Create();
            _apprenticeshipResponse = _autoFixture.Create <GetApprenticeshipResponse>();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);

            _mapper = new WhatIsTheNewStartDateViewModelMapper(_mockCommitmentsApiClient.Object);
        }
コード例 #5
0
        public async Task Then_The_Apprenticeships_Are_Not_Returned_If_Opted_Out(
            GetApplicationQuery query,
            IncentiveApplicationDto applicationResponse,
            GetApprenticeshipResponse apprenticeshipResponse,
            [Frozen] Mock <ICommitmentsApiClient <CommitmentsConfiguration> > commitmentsClient,
            [Frozen] Mock <IApplicationService> applicationService,
            GetApplicationHandler handler
            )
        {
            query.IncludeApprenticeships = false;

            applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.Application.Apprenticeships.Count().Should().Be(0);
            commitmentsClient.Verify(client => client.Get <GetApprenticeshipResponse>(It.IsAny <GetApprenticeshipRequest>()), Times.Never);
        }
        public void Arrange()
        {
            var autoFixture = new Fixture();

            _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                      .With(a => a.Status, ApprenticeshipStatus.Stopped)
                                      .Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(a => a.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);

            _mockEncodingService = new Mock <IEncodingService>();
            _mockEncodingService.Setup(d => d.Decode(It.IsAny <string>(), EncodingType.ApprenticeshipId))
            .Returns(ApprenticeshipId);

            _mapper = new ChangeProviderInformViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object);
        }
コード例 #7
0
        public async Task ThenAccountLegalEntityPublicHashedIdIsMapped(GetApprenticeshipResponse mediatorResponse)
        {
            const string accountLegalEntityPublicHashedId = "XXX999";

            mediatorResponse.Data.AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId;
            _mockMediator.Setup(x => x.SendAsync(It.IsAny <GetApprenticeshipRequest>())).ReturnsAsync(mediatorResponse);

            // for this unit test we want a controller where the employerOrchestrator contains a real ApprenticeshipMapper
            _employerOrchestrator = new EmployerOrchestrator(_mockMediator.Object, Mock.Of <ICommitmentsLogger>(), new FacetMapper(Mock.Of <ICurrentDateTime>()), new ApprenticeshipFilterService(new FacetMapper(Mock.Of <ICurrentDateTime>())),
                                                             new ApprenticeshipMapper(), _commitmentMapper.Object, Mock.Of <ITransferRequestMapper>(), Mock.Of <IHashingService>());

            _controller = new EmployerController(_employerOrchestrator, _apprenticeshipsOrchestrator);

            var result = await _controller.GetApprenticeship(TestProviderId, TestApprenticeshipId) as OkNegotiatedContentResult <Apprenticeship.Apprenticeship>;

            result.Content.Should().NotBeNull();
            Assert.AreEqual(accountLegalEntityPublicHashedId, result.Content.AccountLegalEntityPublicHashedId);
        }
        public void Arrange()
        {
            var _autoFixture = new Fixture();

            _dataLockRequestRestartRequest = _autoFixture.Create <DataLockRequestRestartRequest>();

            DataLocksWithCourseMismatch = new List <DataLock>
            {
                new DataLock
                {
                    IsResolved            = false,
                    DataLockStatus        = Status.Fail,
                    ErrorCode             = DataLockErrorCode.Dlock04,
                    IlrTrainingCourseCode = "454-3-1",
                    IlrEffectiveFromDate  = DateTime.Now.Date.AddDays(15)
                }
            };
            _getDataLockSummariesResponse = _autoFixture.Build <GetDataLockSummariesResponse>().With(x => x.DataLocksWithCourseMismatch, DataLocksWithCourseMismatch).Create();

            _getApprenticeshipResponse = _autoFixture.Build <GetApprenticeshipResponse>()
                                         .With(p => p.CourseCode, "111")
                                         .With(p => p.CourseName, "Training 111")
                                         .With(p => p.EndDate, DateTime.Now.Date.AddDays(100))
                                         .Create();


            TrainingProgrammes = new List <TrainingProgramme>
            {
                new TrainingProgramme {
                    CourseCode = "454-3-1", ProgrammeType = ProgrammeType.Standard, Name = "Training 111"
                }
            };
            _getAllTrainingProgrammesResponse = _autoFixture.Build <GetAllTrainingProgrammesResponse>().With(x => x.TrainingProgrammes, TrainingProgrammes).Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeshipDatalockSummariesStatus(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getDataLockSummariesResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);
            _mockCommitmentsApiClient.Setup(m => m.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getAllTrainingProgrammesResponse);

            _mapper = new DataLockRequestRestartRequestToViewModelMapper(_mockCommitmentsApiClient.Object);
        }
        public void Arrange()
        {
            var _autoFixture = new Fixture();

            var test = DateTime.UtcNow.Year;

            _request = _autoFixture.Create <ChangeOfProviderRequest>();
            _request.NewStartYear   = DateTime.UtcNow.Year;
            _request.NewStartMonth  = DateTime.UtcNow.Month;
            _request.NewEndYear     = DateTime.UtcNow.AddYears(1).Year;
            _request.NewEndMonth    = DateTime.UtcNow.AddYears(1).Month;
            _apprenticeshipResponse = _autoFixture.Create <GetApprenticeshipResponse>();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(m => m.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);

            _mapper = new WhatIsTheNewPriceViewModelMapper(_mockCommitmentsApiClient.Object);
        }
        public void Arrange()
        {
            var fixture = new Fixture();

            _source = fixture.Build <PriceRequest>().Without(x => x.Price).Create();

            _getApprenticeshipApiResponse = new GetApprenticeshipResponse {
                EmployerName = "TestName"
            };

            _commitmentsApiClientMock = new Mock <ICommitmentsApiClient>();
            _commitmentsApiClientMock
            .Setup(x => x.GetApprenticeship(_source.ApprenticeshipId, default(CancellationToken)))
            .ReturnsAsync(_getApprenticeshipApiResponse);

            _mapper = new PriceViewModelMapper(_commitmentsApiClientMock.Object);

            _act = async() => await _mapper.Map(TestHelper.Clone(_source));
        }
コード例 #11
0
        public async Task GetApprenticeshipConfirmationStatus_IsMappedCorrectly(ConfirmationStatus?confirmationStatus)
        {
            // Arrange
            _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                      .With(x => x.Id, ApprenticeshipIdFirst)
                                      .With(x => x.CourseCode, "ABC")
                                      .With(x => x.Version, "1.0")
                                      .With(x => x.DateOfBirth, autoFixture.Create <DateTime>())
                                      .With(x => x.ConfirmationStatus, confirmationStatus).Create();

            _mockCommitmentsApiClient.Setup(x => x.GetApprenticeship(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_apprenticeshipResponse);

            // Act
            var result = await _mapper.Map(_request);

            // Assert
            Assert.AreEqual(result.ConfirmationStatus, confirmationStatus);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _request = _fixture.Create <ChangeVersionRequest>();

            _getApprenticeshipResponse = _fixture.Build <GetApprenticeshipResponse>()
                                         .With(x => x.Version, "1.1")
                                         .With(x => x.StandardUId, "ST0001_1.1")
                                         .Create();

            var currentTrainingProgramme = _fixture.Build <TrainingProgramme>().Create();

            _getCurrentVersionResponse = new GetTrainingProgrammeResponse
            {
                TrainingProgramme = currentTrainingProgramme
            };

            var newerVersion = _fixture.Build <TrainingProgramme>()
                               .With(x => x.Version, "1.2")
                               .Create();

            _getNewerVersionsResponse = new GetNewerTrainingProgrammeVersionsResponse
            {
                NewerVersions = new List <TrainingProgramme> {
                    newerVersion
                }
            };

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(_request.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetTrainingProgrammeVersionByStandardUId(_getApprenticeshipResponse.StandardUId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getCurrentVersionResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetNewerTrainingProgrammeVersions(_getApprenticeshipResponse.StandardUId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getNewerVersionsResponse);

            _mapper = new ChangeVersionViewModelMapper(_mockCommitmentsApiClient.Object);
        }
コード例 #13
0
 public StartDateViewModelMapperFixture()
 {
     Request = new StartDateRequest
     {
         ApprenticeshipHashedId = "SF45G54",
         ApprenticeshipId       = 234,
         ProviderId             = 645621,
         EmployerAccountLegalEntityPublicHashedId = "GD35SD35"
     };
     Response = new GetApprenticeshipResponse
     {
         StopDate     = DateTime.UtcNow.AddDays(-5),
         EmployerName = "TestName"
     };
     _commitmentsApiClientMock = new Mock <ICommitmentsApiClient>();
     _commitmentsApiClientMock
     .Setup(x => x.GetApprenticeship(Request.ApprenticeshipId, CancellationToken.None))
     .ReturnsAsync(Response);
     _sut = new StartDateViewModelMapper(_commitmentsApiClientMock.Object);
 }
        public void Arrange()
        {
            var autoFixture = new Fixture();

            _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                      .Create();
            _providerResponse = autoFixture.Build <GetProviderResponse>()
                                .Create();
            _request = autoFixture.Build <SendNewTrainingProviderRequest>()
                       .Create();


            _commitmentApiClient = new Mock <ICommitmentsApiClient>();
            _commitmentApiClient.Setup(a => a.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);

            _commitmentApiClient.Setup(a => a.GetProvider(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_providerResponse);

            _sut = new SendNewTrainingProviderViewModelMapper(_commitmentApiClient.Object, Mock.Of <ILogger <SendNewTrainingProviderViewModelMapper> >());
        }
        public void Arrange()
        {
            _autoFixture = new Fixture();

            _changeOfPartyResponse = _autoFixture.Build <GetChangeOfPartyRequestsResponse>()
                                     .With(r => r.ChangeOfPartyRequests, GetChangeOfPartyRequestsMock())
                                     .Create();
            _apprenticeshipResponse = _autoFixture.Build <GetApprenticeshipResponse>()
                                      .Create();
            _priceEpisodesResponse = _autoFixture.Build <GetPriceEpisodesResponse>()
                                     .With(p => p.PriceEpisodes, GetPriceEpisodesMock())
                                     .Create();
            _providerResponse = _autoFixture.Build <GetProviderResponse>()
                                .Create();
            _request = _autoFixture.Build <ViewChangesRequest>()
                       .Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApiClient.Setup(c => c.GetChangeOfPartyRequests(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_changeOfPartyResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_priceEpisodesResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetProvider(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_providerResponse);

            _mockEncodingService = new Mock <IEncodingService>();
            _mockEncodingService.Setup(c => c.Encode(It.IsAny <long>(), EncodingType.CohortReference))
            .Returns(_cohortReference);

            _mockCommitmentsApiClient.Setup(c => c.GetCohort(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(GetCohortResponseMock());

            _mapper = new ViewChangesViewModelMapper(_mockCommitmentsApiClient.Object, _mockEncodingService.Object);
        }
        public void Arrange()
        {
            var autoFixture = new Fixture();

            _apprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                      .With(a => a.FirstName, "FirstName")
                                      .With(a => a.LastName, "LastName")
                                      .Create();

            _providerResponse = autoFixture.Build <GetProviderResponse>()
                                .With(p => p.Name, "Test Provider")
                                .Create();

            _mockCommitmentsApi = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApi.Setup(c => c.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apprenticeshipResponse);
            _mockCommitmentsApi.Setup(c => c.GetProvider(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_providerResponse);

            _mapper = new ChangeProviderRequestedConfirmationViewModelMapper(_mockCommitmentsApi.Object);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _viewModel = _fixture.Create <ChangeVersionViewModel>();
            _getApprenticeshipResponse = _fixture.Create <GetApprenticeshipResponse>();

            var priceEpisode = _fixture.Build <PriceEpisode>()
                               .With(x => x.ApprenticeshipId, _getApprenticeshipResponse.Id)
                               .With(x => x.FromDate, _getApprenticeshipResponse.StartDate.AddDays(-1))
                               .Without(x => x.ToDate)
                               .Create();

            _getPriceEpisodesResponse = _fixture.Build <GetPriceEpisodesResponse>()
                                        .With(x => x.PriceEpisodes, new List <PriceEpisode> {
                priceEpisode
            })
                                        .Create();

            var trainingProgramme = _fixture.Build <TrainingProgramme>().With(x => x.Name, _getApprenticeshipResponse.CourseName).Create();

            _getVersionResponse = new GetTrainingProgrammeResponse {
                TrainingProgramme = trainingProgramme
            };

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(_viewModel.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(_viewModel.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getPriceEpisodesResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetTrainingProgrammeVersionByCourseCodeAndVersion(_getApprenticeshipResponse.CourseCode, _viewModel.SelectedVersion, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getVersionResponse);

            _mapper = new ChangeVersionViewModelToEditApprenticehipRequestViewModelMapper(_mockCommitmentsApiClient.Object);
        }
            public ViewApprenticeshipUpdatesRequestToViewModelMapperTestsFixture()
            {
                var autoFixture = new Fixture();

                autoFixture.Customizations.Add(new DateTimeSpecimenBuilder());
                CommitmentApiClient = new Mock <ICommitmentsApiClient>();

                Source = new ViewApprenticeshipUpdatesRequest {
                    ApprenticeshipId = ApprenticeshipId, ProviderId = 22, ApprenticeshipHashedId = "XXX"
                };
                GetApprenticeshipResponse         = autoFixture.Create <GetApprenticeshipResponse>();
                GetApprenticeshipResponse.Id      = ApprenticeshipId;
                autoFixture.RepeatCount           = 1;
                GetApprenticeshipUpdatesResponses = autoFixture.Create <GetApprenticeshipUpdatesResponse>();
                ApprenticeshipUpdate         = GetApprenticeshipUpdatesResponses.ApprenticeshipUpdates.First();
                GetTrainingProgrammeResponse = autoFixture.Create <GetTrainingProgrammeResponse>();

                var priceEpisode = new GetPriceEpisodesResponse
                {
                    PriceEpisodes = new List <GetPriceEpisodesResponse.PriceEpisode>()
                    {
                        new GetPriceEpisodesResponse.PriceEpisode
                        {
                            FromDate = DateTime.UtcNow.AddDays(-10),
                            ToDate   = null,
                            Cost     = 100
                        }
                    }
                };

                CommitmentApiClient.Setup(x => x.GetApprenticeship(ApprenticeshipId, It.IsAny <CancellationToken>())).Returns(() => Task.FromResult(GetApprenticeshipResponse));
                CommitmentApiClient.Setup(x => x.GetApprenticeshipUpdates(ApprenticeshipId, It.IsAny <GetApprenticeshipUpdatesRequest>(), It.IsAny <CancellationToken>())).Returns(() => Task.FromResult(GetApprenticeshipUpdatesResponses));
                CommitmentApiClient.Setup(x => x.GetPriceEpisodes(ApprenticeshipId, It.IsAny <CancellationToken>())).Returns(() => Task.FromResult(priceEpisode));
                CommitmentApiClient.Setup(x => x.GetTrainingProgramme(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(() => Task.FromResult(GetTrainingProgrammeResponse));

                Mapper = new ViewApprenticeshipUpdatesRequestToViewModelMapper(CommitmentApiClient.Object);
            }
コード例 #19
0
        public void Setup()
        {
            var fixture = new Fixture();

            _query = fixture.Create <GetConfirmEmployerQuery>();

            _accountLegalEntityApiResponse = fixture.Create <GetAccountLegalEntityResponse>();
            _apprenticeshipApiResponse     = fixture.Build <GetApprenticeshipResponse>()
                                             .With(x => x.ProviderId, _query.ProviderId)
                                             .Create();

            _commitmentsApiClient = new Mock <ICommitmentsV2ApiClient <CommitmentsV2ApiConfiguration> >();

            _commitmentsApiClient.Setup(x =>
                                        x.Get <GetAccountLegalEntityResponse>(
                                            It.Is <GetAccountLegalEntityRequest>(x =>
                                                                                 x.AccountLegalEntityId == _query.AccountLegalEntityId)))
            .ReturnsAsync(_accountLegalEntityApiResponse);

            _commitmentsApiClient.Setup(x =>
                                        x.Get <GetApprenticeshipResponse>(
                                            It.Is <GetApprenticeshipRequest>(x =>
                                                                             x.ApprenticeshipId == _query.ApprenticeshipId)))
            .ReturnsAsync(_apprenticeshipApiResponse);

            _flexiJobAgencyApiClient = new Mock <IFjaaApiClient <FjaaApiConfiguration> >();
            _flexiJobAgencyApiClient.Setup(x => x
                                           .GetWithResponseCode <GetAgencyResponse>(It.IsAny <GetAgencyRequest>()))
            .ReturnsAsync(new ApiResponse <GetAgencyResponse>(null, HttpStatusCode.NotFound, string.Empty));

            var featureToggles = new FeatureToggles {
                ApprovalsFeatureToggleFjaaEnabled = true
            };

            _handler = new GetConfirmEmployerQueryHandler(_commitmentsApiClient.Object, _flexiJobAgencyApiClient.Object, featureToggles);
        }
        public void Arrange()
        {
            _fixture = new Fixture();

            _viewModel = _fixture.Create <ChangeOptionViewModel>();

            var baseDate = DateTime.Now;

            var startDate   = baseDate;
            var endDate     = baseDate.AddYears(2);
            var dateOfBirth = baseDate.AddYears(-18);

            _getApprenticeshipResponse = _fixture.Build <GetApprenticeshipResponse>()
                                         .With(x => x.StartDate, startDate)
                                         .With(x => x.EndDate, endDate)
                                         .With(x => x.DateOfBirth, dateOfBirth)
                                         .Create();

            _editViewModel = _fixture.Build <EditApprenticeshipRequestViewModel>()
                             .With(x => x.CourseCode, _getApprenticeshipResponse.CourseCode)
                             .With(x => x.Version, _getApprenticeshipResponse.Version)
                             .With(x => x.StartDate, new MonthYearModel(startDate.ToString("MMyyyy")))
                             .With(x => x.EndDate, new MonthYearModel(endDate.ToString("MMyyyy")))
                             .With(x => x.DateOfBirth, new MonthYearModel(dateOfBirth.ToString("MMyyyy")))
                             .Create();

            var priceEpisode = _fixture.Build <PriceEpisode>()
                               .With(x => x.ApprenticeshipId, _getApprenticeshipResponse.Id)
                               .With(x => x.FromDate, _getApprenticeshipResponse.StartDate.AddDays(-1))
                               .Without(x => x.ToDate)
                               .Create();

            _getPriceEpisodesResponse = _fixture.Build <GetPriceEpisodesResponse>()
                                        .With(x => x.PriceEpisodes, new List <PriceEpisode> {
                priceEpisode
            })
                                        .Create();

            var trainingProgramme = _fixture.Build <TrainingProgramme>().With(x => x.Name, _getApprenticeshipResponse.CourseName).Create();

            _getVersionResponse = new GetTrainingProgrammeResponse {
                TrainingProgramme = trainingProgramme
            };

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();

            _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(_viewModel.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getApprenticeshipResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(_viewModel.ApprenticeshipId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getPriceEpisodesResponse);

            _mockCommitmentsApiClient.Setup(c => c.GetTrainingProgrammeVersionByCourseCodeAndVersion(_getApprenticeshipResponse.CourseCode, _getApprenticeshipResponse.Version, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_getVersionResponse);

            _mockTempDataDictionary = new Mock <ITempDataDictionary>();

            _mockTempDataFactory = new Mock <ITempDataDictionaryFactory>();
            _mockTempDataFactory.Setup(f => f.GetTempData(It.IsAny <HttpContext>()))
            .Returns(_mockTempDataDictionary.Object);

            _mapper = new ChangeOptionViewModelToEditApprenticeshipRequestViewModelMapper(
                _mockCommitmentsApiClient.Object,
                Mock.Of <IHttpContextAccessor>(),
                _mockTempDataFactory.Object);
        }
 private bool HasHadDataLockSuccess(GetApprenticeshipResponse apprenticeship)
 {
     return(apprenticeship.HasHadDataLockSuccess);
 }
 private bool IsWaitingToStartAndHasHadDataLockSuccessAndIsFundedByTransfer(GetApprenticeshipResponse apprenticeship, GetCohortResponse commitment)
 {
     return(commitment.IsFundedByTransfer &&
            HasHadDataLockSuccess(apprenticeship) &&
            IsWaitingToStart(apprenticeship));
 }
コード例 #23
0
 public void SetUpGetApprenticeship(GetApprenticeshipResponse response)
 {
     _mockCommitmentsApiClient.Setup(c => c.GetApprenticeship(It.IsAny <long>(), It.IsAny <CancellationToken>()))
     .ReturnsAsync(response);
 }
コード例 #24
0
        public EditApprenticeshipRequestToViewModelMapperTestsFixture()
        {
            //Arrange
            var autoFixture = new Fixture();

            _request = autoFixture.Build <EditApprenticeshipRequest>()
                       .With(x => x.AccountHashedId, "123")
                       .With(x => x.ApprenticeshipHashedId, "456")
                       .Create();
            ApprenticeshipResponse = autoFixture.Build <GetApprenticeshipResponse>()
                                     .With(x => x.CourseCode, "ABC")
                                     .With(x => x.Version, "1.0")
                                     .With(x => x.DateOfBirth, autoFixture.Create <DateTime>())
                                     .Create();
            _priceEpisodesResponse = autoFixture.Build <GetPriceEpisodesResponse>()
                                     .With(x => x.PriceEpisodes, new List <PriceEpisode> {
                new PriceEpisode {
                    Cost = 1000, ToDate = DateTime.Now.AddMonths(-1)
                }
            })
                                     .Create();

            _cohortResponse  = autoFixture.Create <GetCohortResponse>();
            _accountResponse = autoFixture.Create <AccountResponse>();
            _allTrainingProgrammeStandardsResponse = autoFixture.Create <GetAllTrainingProgrammeStandardsResponse>();
            _allTrainingProgrammeResponse          = autoFixture.Create <GetAllTrainingProgrammesResponse>();

            _trainingProgrammeResponse = autoFixture.Build <GetTrainingProgrammeResponse>().Create();

            _mockCommitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _mockCommitmentsApiClient.Setup(r => r.GetApprenticeship(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(ApprenticeshipResponse);
            _mockCommitmentsApiClient.Setup(c => c.GetPriceEpisodes(It.IsAny <long>(), CancellationToken.None))
            .ReturnsAsync(_priceEpisodesResponse);

            _mockCommitmentsApiClient.Setup(t => t.GetTrainingProgramme(ApprenticeshipResponse.CourseCode, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_trainingProgrammeResponse);

            _mockCommitmentsApiClient.Setup(t => t.GetCohort(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => _cohortResponse);

            _mockCommitmentsApiClient.Setup(t => t.GetAccount(_request.AccountId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => _accountResponse);

            _mockCommitmentsApiClient.Setup(t => t.GetAllTrainingProgrammeStandards(It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => {
                _courses = _allTrainingProgrammeStandardsResponse.TrainingProgrammes;
                return(_allTrainingProgrammeStandardsResponse);
            });

            _mockCommitmentsApiClient.Setup(t => t.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(() => {
                _courses = _allTrainingProgrammeResponse.TrainingProgrammes;
                return(_allTrainingProgrammeResponse);
            });

            _mockAcademicYearDateProvider = new Mock <IAcademicYearDateProvider>();

            _mockCurrentDateTimeProvider = new Mock <ICurrentDateTime>();

            _mapper = new EditApprenticeshipRequestToViewModelMapper(_mockCommitmentsApiClient.Object, _mockAcademicYearDateProvider.Object, _mockCurrentDateTimeProvider.Object);
        }
 private bool IsLiveAndHasHadDataLockSuccess(GetApprenticeshipResponse apprenticeship)
 {
     return(IsLive(apprenticeship) && HasHadDataLockSuccess(apprenticeship));
 }
 private bool IsLiveAndIsNotWithInFundingPeriod(GetApprenticeshipResponse apprenticeship)
 {
     return(IsLive(apprenticeship) && !IsWithInFundingPeriod(apprenticeship.StartDate));
 }
 private bool IsWaitingToStart(GetApprenticeshipResponse apprenticeship)
 {
     return(apprenticeship.Status == ApprenticeshipStatus.WaitingToStart);
 }
コード例 #28
0
        public IChangeEmployerViewModelMapperTestsFixture()
        {
            AutoFixture = new Fixture();

            ProviderId             = 123;
            ApprenticeshipId       = 234;
            ApprenticeshipHashedId = "SD23DS24";
            EmployerName           = AutoFixture.Create <string>();
            StartDate                  = AutoFixture.Create <DateTime>();
            EndDate                    = AutoFixture.Create <DateTime>();
            Price                      = AutoFixture.Create <int>();
            CohortReference            = AutoFixture.Create <string>();
            EncodedNewApprenticeshipId = AutoFixture.Create <string>();

            _changeEmployerRequest = new ChangeEmployerRequest
            {
                ApprenticeshipId       = ApprenticeshipId,
                ProviderId             = ProviderId,
                ApprenticeshipHashedId = ApprenticeshipHashedId
            };

            Apprenticeship = new GetApprenticeshipResponse
            {
                EmployerName = AutoFixture.Create <string>(),
                StartDate    = AutoFixture.Create <DateTime>()
            };

            PriceEpisodes = new GetPriceEpisodesResponse
            {
                PriceEpisodes = new List <GetPriceEpisodesResponse.PriceEpisode>
                {
                    new GetPriceEpisodesResponse.PriceEpisode
                    {
                        FromDate = DateTime.MinValue,
                        Cost     = AutoFixture.Create <int>()
                    }
                }
            };

            ChangeOfPartyRequests = new GetChangeOfPartyRequestsResponse
            {
                ChangeOfPartyRequests = new List <GetChangeOfPartyRequestsResponse.ChangeOfPartyRequest>()
            };

            _commitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _commitmentsApiClient
            .Setup(x => x.GetChangeOfPartyRequests(It.Is <long>(a => a == ApprenticeshipId),
                                                   It.IsAny <CancellationToken>())).ReturnsAsync(ChangeOfPartyRequests);

            _commitmentsApiClient.Setup(x => x.GetApprenticeship(It.Is <long>(a => a == ApprenticeshipId),
                                                                 It.IsAny <CancellationToken>())).ReturnsAsync(Apprenticeship);

            _commitmentsApiClient.Setup(x => x.GetPriceEpisodes(It.Is <long>(a => a == ApprenticeshipId),
                                                                It.IsAny <CancellationToken>())).ReturnsAsync(PriceEpisodes);

            _encodingService = new Mock <IEncodingService>();
            _encodingService.Setup(x => x.Encode(It.IsAny <long>(), EncodingType.CohortReference))
            .Returns(CohortReference);

            _encodingService.Setup(x => x.Encode(It.IsAny <long>(), EncodingType.ApprenticeshipId))
            .Returns(EncodedNewApprenticeshipId);

            _sut = new IChangeEmployerViewModelMapper(_commitmentsApiClient.Object, _encodingService.Object);
        }
        public async Task GetApprenticeship_ReturnsApprenticeship_WhenApiCallSucceeds([Frozen] Mock <ICommitmentsApiClient> apiClient, EmployerCommitmentsService sut, long apprenticeshipId, GetApprenticeshipResponse response)
        {
            //Given
            apiClient.Setup(s => s.GetApprenticeship(apprenticeshipId, It.IsAny <CancellationToken>())).ReturnsAsync(response);

            //When
            var result = await sut.GetApprenticeship(apprenticeshipId, new CancellationToken());

            //Then
            result.Apprenticeship.Should().BeEquivalentTo(new
            {
                response.Id,
                response.EmployerAccountId,
                response.EmployerName,
                Ukprn = response.ProviderId,
                response.ProviderName,
                response.AccountLegalEntityId,
                response.FirstName,
                response.LastName,
                response.StartDate,
                response.EndDate,
                ApprenticeshipStatus = response.Status,
                response.Uln
            });
        }
        private IList <DataLockCourseChange> MapCourseChanges(IEnumerable <DataLock> dataLocks, GetApprenticeshipResponse apprenticeship, IReadOnlyCollection <GetPriceEpisodesResponse.PriceEpisode> priceHistory, IEnumerable <TrainingProgramme> trainingProgrammes)
        {
            var earliestPriceHistory = priceHistory.Min(x => x.FromDate);

            return(dataLocks
                   .Where(m => m.TriageStatus == TriageStatus.Change)
                   .Select(dataLock =>
            {
                return new DataLockCourseChange
                {
                    CurrentStartDate = earliestPriceHistory,
                    CurrentEndDate = apprenticeship.EndDate,
                    CurrentTrainingProgram = apprenticeship.CourseName,
                    IlrStartDate = dataLock.IlrEffectiveFromDate.Value,
                    IlrEndDate = dataLock.IlrPriceEffectiveToDate,
                    IlrTrainingProgram = trainingProgrammes.FirstOrDefault(p => p.CourseCode == dataLock.IlrTrainingCourseCode)?.Name
                };
            }).ToList());
        }