Exemplo n.º 1
0
 public WhenRequestingReviewApprenticeshipUpdatesTestsixture() : base()
 {
     Request = new ReviewApprenticeshipUpdatesRequest {
         ApprenticeshipId = 1, AccountId = 1
     };
     _controller.TempData = new TempDataDictionary(Mock.Of <HttpContext>(), Mock.Of <ITempDataProvider>());
 }
        public GetReviewApprenticeshipUpdatesFixture()
        {
            var fixture = new Fixture();

            _providerId = 123;
            _request    = new ReviewApprenticeshipUpdatesRequest {
                ProviderId = _providerId, ApprenticeshipHashedId = "XYZ"
            };
            _modelMapperMock = new Mock <IModelMapper>();
            _viewModel       = fixture.Create <ReviewApprenticeshipUpdatesViewModel>();

            _modelMapperMock
            .Setup(x => x.Map <ReviewApprenticeshipUpdatesViewModel>(_request))
            .ReturnsAsync(_viewModel);

            Sut = new ApprenticeController(_modelMapperMock.Object, Mock.Of <ICookieStorageService <IndexRequest> >(), Mock.Of <ICommitmentsApiClient>());
        }
Exemplo n.º 3
0
            public ReviewApprenticeshipUpdatesRequestToViewModelMapperTestsFixture()
            {
                var autoFixture = new Fixture();

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

                Source = new ReviewApprenticeshipUpdatesRequest {
                    ApprenticeshipId = ApprenticeshipId, ProviderId = 22, ApprenticeshipHashedId = "XXX"
                };
                GetApprenticeshipResponse         = autoFixture.Create <GetApprenticeshipResponse>();
                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 ReviewApprenticeshipUpdatesRequestToViewModelMapper(CommitmentApiClient.Object);
            }
        public async Task <IActionResult> ReviewApprenticeshipUpdates(ReviewApprenticeshipUpdatesRequest request)
        {
            var viewModel = await _modelMapper.Map <ReviewApprenticeshipUpdatesViewModel>(request);

            return(View(viewModel));
        }