Esempio n. 1
0
        public async Task Then_Returns_Sectors(
            GetSectorsQueryResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] ReferenceController referenceController)
        {
            mockMediator
            .Setup(x => x.Send(It.IsAny <GetSectorsQuery>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(queryResult);

            var controllerResult = await referenceController.Sectors() as ObjectResult;

            Assert.IsNotNull(controllerResult);
            Assert.AreEqual(controllerResult.StatusCode, (int)HttpStatusCode.OK);

            var model = controllerResult.Value as IEnumerable <ReferenceDataItem>;

            Assert.IsNotNull(model);
        }
        public async Task Then_Gets_Sectors_From_Mediator(
            GetSectorsQueryResult mediatorResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] SectorsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetSectorsQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(mediatorResult);

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

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

            Assert.IsNotNull(model);

            foreach (var sector in model.Sectors)
            {
                mediatorResult.Sectors.Should().Contain(c => c.Name.Equals(sector.Route));
            }
        }