Example #1
0
        public async Task TransferFundedCohortsAllowStandardCoursesOnlyWhenEmployerIsLevy()
        {
            _source.TransferSenderId = "test";
            _result = await _mapper.Map(TestHelper.Clone(_source));

            _result.Courses.Should().BeEquivalentTo(_standardTrainingProgrammes);
        }
Example #2
0
        public async Task CoursesAreMappedCorrectlyWithLevy(long?transferSenderId, bool fundedByTransfer)
        {
            _cohort.LevyStatus       = ApprenticeshipEmployerType.Levy;
            _cohort.TransferSenderId = transferSenderId;

            _result = await _mapper.Map(_source);

            Assert.AreEqual(fundedByTransfer
                    ?  _standardTrainingProgrammes
                    : _allTrainingProgrammes,
                            _result.Courses);
        }
Example #3
0
        public async Task Arrange()
        {
            var autoFixture = new Fixture();

            _allTrainingProgrammes      = autoFixture.CreateMany <TrainingProgramme>().ToList();
            _standardTrainingProgrammes = autoFixture.CreateMany <TrainingProgramme>().ToList();

            _cohort               = autoFixture.Create <GetCohortResponse>();
            _cohort.WithParty     = Party.Employer;
            _commitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _commitmentsApiClient.Setup(x => x.GetCohort(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_cohort);

            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammeStandards(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammeStandardsResponse
            {
                TrainingProgrammes = _standardTrainingProgrammes
            });

            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammesResponse
            {
                TrainingProgrammes = _allTrainingProgrammes
            });

            _encodedTransferSenderId = autoFixture.Create <string>();
            _encodingService         = new Mock <IEncodingService>();
            _encodingService
            .Setup(x => x.Encode(It.IsAny <long>(), It.Is <EncodingType>(e => e == EncodingType.PublicAccountId)))
            .Returns(_encodedTransferSenderId);

            _mapper = new AddDraftApprenticeshipViewModelMapper(_commitmentsApiClient.Object, _encodingService.Object);

            _source = autoFixture.Create <AddDraftApprenticeshipRequest>();
            _source.StartMonthYear = "092020";

            _result = await _mapper.Map(TestHelper.Clone(_source));
        }
Example #4
0
        public async Task Arrange()
        {
            var autoFixture = new Fixture();

            _standardTrainingProgrammes = autoFixture.CreateMany <TrainingProgramme>().ToList();
            _allTrainingProgrammes      = autoFixture.CreateMany <TrainingProgramme>().ToList();
            _providerResponse           = autoFixture.Create <GetProviderResponse>();
            _accountLegalEntityResponse = autoFixture.Build <AccountLegalEntityResponse>().With(x => x.LevyStatus, ApprenticeshipEmployerType.Levy).Create();

            _source = autoFixture.Build <ApprenticeRequest>()
                      .With(x => x.StartMonthYear, "062020")
                      .With(x => x.AccountId, 12345)
                      .Without(x => x.TransferSenderId).Create();

            _commitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _commitmentsApiClient.Setup(x => x.GetProvider(It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_providerResponse);
            _commitmentsApiClient.Setup(x => x.GetAccountLegalEntity(_source.AccountLegalEntityId, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_accountLegalEntityResponse);
            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammeStandards(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammeStandardsResponse()
            {
                TrainingProgrammes = _standardTrainingProgrammes
            });
            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammesResponse
            {
                TrainingProgrammes = _allTrainingProgrammes
            });

            _mapper = new AddDraftApprenticeshipViewModelMapper(_commitmentsApiClient.Object);

            _result = await _mapper.Map(TestHelper.Clone(_source));
        }
Example #5
0
        public async Task ThenAccountLegalEntityIdIsMappedCorrectly()
        {
            var result = await _mapper.Map(_source);

            Assert.AreEqual(_source.AccountLegalEntityId, result.AccountLegalEntityId);
        }