Esempio n. 1
0
    public async Task GivenWeAreShippingAnOrder_WhenOrderDoesNotExist_ThenShouldReturnNotFound()
    {
        _commandBrokerMoq.Setup(x => x.SendAsync(It.IsAny <ShipOrder>()))
        .ReturnsAsync(new CommandResult <Order>(CommandOutcome.NotFound));
        var controller = new OrderCommandController(_commandBrokerMoq.Object, _mapper);

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

        var notFoundResult = actionResult as NotFoundResult;

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

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

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

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

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