Example #1
0
        public async Task Then_Gets_Routes_From_Mediator(
            GetRoutesQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] RoutesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetRoutesQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

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

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

            Assert.IsNotNull(model);

            foreach (var sector in model.Routes)
            {
                mediatorResult.Routes.Should().Contain(c => c.Name.Equals(sector.Route));
                mediatorResult.Routes.Should().Contain(c => c.Id.Equals(sector.Id));
            }
        }
Example #2
0
        public async Task Then_Gets_Routes_List_From_Mediator(
            GetRoutesQueryResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] RoutesController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetRoutesQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(queryResult);

            var controllerResult = await controller.GetList() as OkObjectResult;

            var model = controllerResult.Value as GetRoutesListResponse;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            model.Routes.Should().BeEquivalentTo(queryResult.Routes);
        }
Example #3
0
        public async Task Then_Gets_Routes_From_Mediator(
            GetRoutesQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ReferenceDataController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetRoutesQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

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

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

            Assert.IsNotNull(model);
            model.Routes.Should().BeEquivalentTo(mediatorResult.Routes.Select(c => (GetRouteResponseItem)c).ToList());
        }