示例#1
0
        public void Arrange()
        {
            _standards = new List <TrainingProgramme>
            {
                new TrainingProgramme
                {
                    CourseCode    = "123",
                    EffectiveFrom = new DateTime(2016, 01, 01),
                    EffectiveTo   = new DateTime(2016, 12, 31)
                }
            };
            _all = new List <TrainingProgramme>
            {
                new TrainingProgramme
                {
                    CourseCode    = "123avc",
                    EffectiveFrom = new DateTime(2017, 01, 01),
                    EffectiveTo   = new DateTime(2017, 12, 31)
                }
            };
            _all.AddRange(_standards);


            _apprenticeshipInfoServiceWrapper = new Mock <IApprenticeshipInfoService>();

            _apprenticeshipInfoServiceWrapper.Setup(x => x.GetAll(It.IsAny <bool>()))
            .ReturnsAsync(new AllTrainingProgrammesView
            {
                CreatedDate        = DateTime.UtcNow,
                TrainingProgrammes = _all
            });

            _apprenticeshipInfoServiceWrapper.Setup(x => x.GetStandards(It.IsAny <bool>()))
            .ReturnsAsync(new StandardsView
            {
                CreationDate = DateTime.UtcNow.Date,
                Standards    = _standards
            });

            _handler = new GetTrainingProgrammesQueryHandler(_apprenticeshipInfoServiceWrapper.Object);
        }
        public async Task Then_Gets_Standards_From_Courses_Api(
            GetTrainingProgrammesQuery query,
            GetStandardsListResponse apiResponse,
            [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > mockApiClient,
            GetTrainingProgrammesQueryHandler handler)
        {
            foreach (var standard in apiResponse.Standards)
            {
                standard.Level = (int)ApprenticeshipLevel.Advanced;
            }
            mockApiClient
            .Setup(client => client.Get <GetFrameworksListResponse>(It.IsAny <GetFrameworksRequest>()))
            .ReturnsAsync(new GetFrameworksListResponse());
            mockApiClient
            .Setup(client => client.Get <GetStandardsListResponse>(It.IsAny <GetActiveStandardsListRequest>()))
            .ReturnsAsync(apiResponse);

            var result = await handler.Handle(query, CancellationToken.None);

            result.TrainingProgrammes.Should().BeEquivalentTo(apiResponse.Standards.Select(item => (TrainingProgramme)item));
        }