Esempio n. 1
0
        public async Task Arrange()
        {
            var autoFixture = new Fixture();

            _request = autoFixture.Create <ViewDraftApprenticeshipRequest>();

            _draftApprenticeship = autoFixture.Create <GetDraftApprenticeshipResponse>();
            _course = autoFixture.Create <TrainingProgramme>();

            _commitmentsApiClient = new Mock <ICommitmentsApiClient>();
            _commitmentsApiClient
            .Setup(x => x.GetTrainingProgramme(_draftApprenticeship.CourseCode, It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetTrainingProgrammeResponse
            {
                TrainingProgramme = _course
            });

            _commitmentsApiClient.Setup(x =>
                                        x.GetDraftApprenticeship(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_draftApprenticeship);

            _authorizationService = new Mock <IAuthorizationService>();

            _mapper = new ViewDraftApprenticeshipViewModelMapper(_commitmentsApiClient.Object, _authorizationService.Object);

            _result = await _mapper.Map(_request) as ViewDraftApprenticeshipViewModel;
        }
        public void Arrange()
        {
            var fixture = new Fixture();

            _apiResponse = fixture.Build <GetDraftApprenticeshipResponse>().Create();
            _apiTrainingProgrammeResponse = fixture.Build <GetTrainingProgrammeResponse>().Create();

            var commitmentsApiClient = new Mock <ICommitmentsApiClient>();

            commitmentsApiClient.Setup(x =>
                                       x.GetDraftApprenticeship(It.IsAny <long>(), It.IsAny <long>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apiResponse);

            commitmentsApiClient.Setup(x => x.GetTrainingProgramme(_apiResponse.CourseCode, It.IsAny <CancellationToken>()))
            .ReturnsAsync(_apiTrainingProgrammeResponse);

            _mapper = new ViewDraftApprenticeshipViewModelMapper(commitmentsApiClient.Object);
            _source = fixture.Build <DraftApprenticeshipRequest>().Create();

            _act = async() => (await _mapper.Map(TestHelper.Clone(_source))) as ViewDraftApprenticeshipViewModel;
        }