예제 #1
0
        public async Task Then_Gets_Standards_By_Sector_From_Mediator(
            string sector,
            GetStandardsQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] TrainingCoursesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetStandardsQuery>(c => c.Sector.Equals(sector)),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetStandardsBySector(sector) as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetStandardsResponse;

            Assert.IsNotNull(model);

            var response = mediatorResult.Standards.Select(s => new GetStandardsResponseItem {
                Id = s.LarsCode
            });

            model.Standards.Should().BeEquivalentTo(response);
        }
예제 #2
0
        public async Task Then_Gets_Standards_From_Mediator(
            GetStandardsQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] TrainingCoursesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetStandardsQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

            var controllerResult = await controller.GetStandards() as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetStandardsListResponse;

            Assert.IsNotNull(model);
            model.Standards.Should().BeEquivalentTo(mediatorResult.Standards.Select(item => (GetStandardResponse)item));
        }
예제 #3
0
        public async Task Then_Returns_Empty_List_If_None_Returned_From_Standards_By_Sector_From_Mediator(
            string sector,
            GetStandardsQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] TrainingCoursesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetStandardsQuery>(c => c.Sector.Equals(sector)),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetStandardsQueryResult());

            var controllerResult = await controller.GetStandardsBySector(sector) as ObjectResult;

            Assert.IsNotNull(controllerResult);
            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var model = controllerResult.Value as GetStandardsResponse;

            Assert.IsNotNull(model);

            model.Standards.Should().BeEmpty();
        }