public async Task DeleteOrderItemReturns404WhenOrderItmNotFound() { Guid orderItemId = Guid.NewGuid(); _mockOrderItemAccess.Reset(); _mockOrderItemAccess.Setup(a => a.RemoveOrderItemAsync(orderItemId, It.IsAny <CancellationToken>())) .ThrowsAsync(new OrderItemNotFoundException(string.Empty)); OrderItemsController sut = CreateSystemUnderTest(); var result = await sut.DeleteAsync(orderItemId, It.IsAny <CancellationToken>()); _mockOrderItemAccess.Verify(a => a.RemoveOrderItemAsync(orderItemId, It.IsAny <CancellationToken>()), Times.Once); Assert.IsType <NotFoundResult>(result); }
public async Task DeleteOrderItemReturnsOkayWhenOrderItemDeleted() { Guid orderItemId = Guid.NewGuid(); _mockOrderItemAccess.Reset(); _mockOrderItemAccess.Setup(a => a.RemoveOrderItemAsync(orderItemId, It.IsAny <CancellationToken>())) .Returns(Task.CompletedTask); OrderItemsController sut = CreateSystemUnderTest(); var result = await sut.DeleteAsync(orderItemId, It.IsAny <CancellationToken>()); _mockOrderItemAccess.Verify(a => a.RemoveOrderItemAsync(orderItemId, It.IsAny <CancellationToken>()), Times.Once); Assert.IsType <OkResult>(result); }