コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }