public void ClearAllItemsAsync_WithNonExistentBasket_ShouldReturnFailure()
        {
            // Arrange
            _basketRepositoryMock.Setup(x => x.GetByUserIdAsync(It.IsAny<string>())).Returns(Task.FromResult<Basket>(null));

            // Act
            var result = _basketService.ClearAllItemsAsync("user").Result;

            // Assert
            Assert.True(result.IsFailure);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ClearAllItems()
        {
            Result result = await _basketService.ClearAllItemsAsync(User.Identity.Name);

            if (result.IsFailure)
            {
                return(NotFound(result.Error));
            }
            return(NoContent());
        }