示例#1
0
        public async Task GetAllStandardsTrainingProgrammes()
        {
            var request  = new TestRequest(new Uri(ExpectedApiBaseUrl + $"api/trainingprogramme/standards"), string.Empty);
            var response = new GetAllTrainingProgrammeStandardsResponse
            {
                TrainingProgrammes = new List <TrainingProgramme>()
            };
            var content = JsonConvert.SerializeObject(response);

            _fakeHandler.AddFakeResponse(request, new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK, Content = new StringContent(content)
            });

            var actual = (await _trainingProgrammeApi.GetAllStandards());

            actual.ShouldBeEquivalentTo(response);
        }
示例#2
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);
        }