public async Task CommandResult_ReturnsNotFound_IfCommandResultNull()
        {
            // Arrange
            var command = new TestCommand();
            var invoker = A.Fake <ICommandInvoker>();

            A.CallTo(() => invoker.Invoke(command, null))
            .Returns(Task.FromResult((ExecutionResponse)null));

            var controller = new TestCommandController(invoker);

            // Act
            var result = await controller.CallCommand(command);

            // Assert
            result.Should().BeOfType <NotFoundResult>();
        }
        public async Task CommandResult_ReturnsStatusCodeOnly_IfStatusCodeHasNoBody(int statusCode)
        {
            // Arrange
            var command           = new TestCommand();
            var actionOutcome     = new ActionOutcome("foobar", statusCode, true);
            var executionResponse = ExecutionResponse.Create("the result", actionOutcome, null);
            var invoker           = A.Fake <ICommandInvoker>();

            A.CallTo(() => invoker.Invoke(command, null))
            .Returns(executionResponse);

            var controller = new TestCommandController(invoker);

            // Act
            var result = await controller.CallCommand(command);

            // Assert
            result.Should().BeOfType <StatusCodeResult>().Which.StatusCode.Should().Be(statusCode);
        }
        public async Task CommandResult_ReturnsStatusCodeAndContent()
        {
            // Arrange
            var command           = new TestCommand();
            var executionResponse = ExecutionResponse.Create("the result", ActionOutcome.Conflict, null);
            var invoker           = A.Fake <ICommandInvoker>();

            A.CallTo(() => invoker.Invoke(command, null))
            .Returns(executionResponse);

            var controller = new TestCommandController(invoker);

            // Act
            var result = (ObjectResult)await controller.CallCommand(command);

            // Assert
            result.StatusCode.Should().Be(409);
            result.Value.Should().Be("the result");
        }