Example #1
0
        public async Task AddProductToCustomerrWishlistAsync_ShouldReturnExistingProduct_WhenProductIsAlreadyInWishlist()
        {
            //Arrange
            string productId = "1bf0f365-fbdd-4e21-9786-da459d78dd1f";

            _customerService.GetCustomerAsync(customerId).Returns(existingCustomer);
            var existingList = new List <WishListProduct>()
            {
                new WishListProduct()
                {
                    ProductId = productId
                }
            };

            _wishlistRepository.GetCustomerWishlistAsync(customerId).Returns(existingList);

            //Act
            var sut     = new WishlistService(_productRest, _customerService, _wishlistRepository);
            var product = await sut.AddProductToCustomerrWishlistAsync(customerId, productId);

            //Assert
            Assert.NotNull(product);
            await _wishlistRepository.DidNotReceive().InsertWishlistProductAsync(Arg.Any <int>(), Arg.Any <WishListProduct>());

            Assert.Equal(productId, product.ProductId);
        }