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

            // Act
            var result = _basketService.ChangeItemQuantityAsync("user", 1, 1).Result;

            // Asert
            Assert.True(result.IsFailure);
        }
Esempio n. 2
0
        public async Task <IActionResult> ChangeItemQuantity(int id, [FromBody] int quantity)
        {
            Result result = await _basketService.ChangeItemQuantityAsync(User.Identity.Name, id, quantity);

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