Ejemplo n.º 1
0
        public async Task And_No_Result_Then_Returns_Not_Found(
            string frameworkId,
            GetFrameworkResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] FrameworksController controller)
        {
            queryResult.Framework = null;
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetFrameworkQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(queryResult);

            var controllerResult = await controller.Get(frameworkId) as StatusCodeResult;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Ejemplo n.º 2
0
        public async Task Then_Gets_Framework_From_Mediator(
            string frameworkId,
            GetFrameworkResult queryResult,
            [Frozen] Mock <IMediator> mockMediator,
            [Greedy] FrameworksController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.Is <GetFrameworkQuery>(c => c.FrameworkId.Equals(frameworkId)),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(queryResult);

            var controllerResult = await controller.Get(frameworkId) as ObjectResult;

            var model = controllerResult.Value as GetFrameworkResponse;

            controllerResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            model.Should().BeEquivalentTo(queryResult.Framework);
        }