Exemple #1
0
    public async Task GivenWeAreCancellingAnOrder_WhenOrderDoesNotExist_ThenShouldReturnNotFound()
    {
        _commandBrokerMoq.Setup(x => x.SendAsync(It.IsAny <CancelOrder>()))
        .ReturnsAsync(new CommandResult <Order>(CommandOutcome.NotFound));
        var controller = new OrderCommandController(_commandBrokerMoq.Object, _mapper);

        var actionResult = await controller.Cancel(Orders.Order2.Id);

        var notFoundResult = actionResult as NotFoundResult;

        Assert.NotNull(actionResult);
        Assert.NotNull(notFoundResult);
    }
Exemple #2
0
    public async Task GivenWeAreCancellingAnOrder_WhenSuccessful_ThenShouldReturnEntity()
    {
        var orderIn    = Orders.Order2;
        var orderOut   = _mapper.Map <Order>(Orders.Order2);
        var controller = new OrderCommandController(_commandBrokerMoq.Object, _mapper);

        _commandBrokerMoq.Setup(x => x.SendAsync(It.IsAny <CancelOrder>()))
        .ReturnsAsync(new CommandResult <Order>(CommandOutcome.Accepted, orderOut));

        var actionResult = await controller.Cancel(orderIn.Id);

        var okResult = Assert.IsType <OkObjectResult>(actionResult);

        Assert.NotNull(actionResult);
        Assert.NotNull(okResult);
        Assert.Equal(orderOut.Id, ((DTO.Write.Order)okResult.Value !).Id);
    }