public void WhenInstantiated_ThenShouldBeOfCorrectType()
    {
        var handler = new UpdateOrderHandler(_repositoryMoq.Object);

        Assert.NotNull(handler);
        Assert.IsType <UpdateOrderHandler>(handler);
    }
    public async Task WhenConcurrencyExceptionOccurs_ThenShouldReturnConflict()
    {
        _repositoryMoq.Setup(x => x.UpdateAsync(It.IsAny <Order>()))
        .ThrowsAsync(new ConcurrencyException());
        var handler = new UpdateOrderHandler(_repositoryMoq.Object);

        var result = await handler.Handle(new UpdateOrder(new Order()), default);

        Assert.NotNull(result);
        Assert.Equal(CommandOutcome.Conflict, result.Outcome);
    }
    public async Task WhenOrderFailsToUpdate_ThenShouldReturnNotFound()
    {
        _repositoryMoq.Setup(x => x.UpdateAsync(It.IsAny <Order>()))
        .ReturnsAsync((Order)null !);
        var handler = new UpdateOrderHandler(_repositoryMoq.Object);

        var result = await handler.Handle(new UpdateOrder(new Order()), default);

        Assert.NotNull(result);
        Assert.Equal(CommandOutcome.NotFound, result.Outcome);
    }
    public async Task WhenOrderIsUpdated_ThenShouldReturnAcceptedEntity()
    {
        var order = _mapper.Map <Order>(Orders.Order1);

        _repositoryMoq.Setup(x => x.UpdateAsync(It.IsAny <Order>()))
        .ReturnsAsync(order);
        var handler = new UpdateOrderHandler(_repositoryMoq.Object);

        var result = await handler.Handle(new UpdateOrder(order), default);

        Assert.NotNull(result);
        Assert.Equal(CommandOutcome.Accepted, result.Outcome);
        Assert.Equal(order.Id, result.Entity !.Id);
    }