Ejemplo n.º 1
0
 public CreateCohortWithDraftApprenticeshipControllerTestFixtures ForGetRequest()
 {
     GetRequest = new ApprenticeRequest {
         ProviderId = 1
     };
     return(this);
 }
        public void Validate_StartDate_ShouldBeValidated(long accountLegalEntityId, bool expectedValid)
        {
            var model = new ApprenticeRequest {
                AccountLegalEntityId = accountLegalEntityId
            };

            AssertValidationResult(request => request.AccountLegalEntityId, model, expectedValid);
        }
        public void Validate_ProviderId_ShouldBeValidated(long providerId, bool expectToBeValid)
        {
            var model = new ApprenticeRequest {
                ProviderId = providerId
            };

            AssertValidationResult(request => request.ProviderId, model, expectToBeValid);
        }
Ejemplo n.º 4
0
        public async Task Arrange()
        {
            var autoFixture = new Fixture();

            _course                     = autoFixture.Create <TrainingProgramme>();
            _courseStandard             = autoFixture.Create <TrainingProgramme>();
            _providerResponse           = autoFixture.Create <GetProviderResponse>();
            _accountLegalEntityResponse = autoFixture.Build <AccountLegalEntityResponse>().With(x => x.LevyStatus, ApprenticeshipEmployerType.Levy).Create();
            _source                     = autoFixture.Create <ApprenticeRequest>();
            _source.StartMonthYear      = "062020";
            _source.TransferSenderId    = string.Empty;
            _source.AccountId           = 12345;

            _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);
            _standardTrainingProgrammes = new List <TrainingProgramme> {
                _courseStandard
            };
            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammeStandards(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammeStandardsResponse
            {
                TrainingProgrammes = _standardTrainingProgrammes
            });
            _allTrainingProgrammes = new List <TrainingProgramme> {
                _courseStandard, _course
            };
            _commitmentsApiClient
            .Setup(x => x.GetAllTrainingProgrammes(It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllTrainingProgrammesResponse
            {
                TrainingProgrammes = _allTrainingProgrammes
            });


            _mapper = new ApprenticeViewModelMapper(
                _commitmentsApiClient.Object);

            _result = await _mapper.Map(TestHelper.Clone(_source));
        }
        private void AssertValidationResult <T>(Expression <Func <ApprenticeRequest, T> > property, ApprenticeRequest instance, bool expectedValid)
        {
            var validator = new CreateCohortWithDraftApprenticeshipRequestValidator();

            if (expectedValid)
            {
                validator.ShouldNotHaveValidationErrorFor(property, instance);
            }
            else
            {
                validator.ShouldHaveValidationErrorFor(property, instance);
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Apprentice(ApprenticeRequest request)
        {
            var model = await _modelMapper.Map <ApprenticeViewModel>(request);

            return(View(model));
        }