public void GetAllProducts()
        {
            ProductCollectionMoq.GetProducts(MockProductRepository, products);
            IList <Product> foundProducts = MockProductRepository.Object.GetProducts();

            Assert.AreEqual(3, foundProducts.Count);
        }
        public void GetProductPriceByKeyWhenProductExists()
        {
            ProductCollectionMoq.GetProductPriceByKey(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            double price = MockProductRepository.Object.GetProductPriceByKey(0);

            Assert.AreEqual(10, price);
        }
        public void RemoveProductWhenIdExists()
        {
            ProductCollectionMoq.RemoveProduct(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            MockProductRepository.Object.RemoveProduct(0);

            IList <Product> foundProducts = MockProductRepository.Object.GetProducts();

            Assert.AreEqual(2, foundProducts.Count);
        }
        public void GetProductPriceByKeyWhenNoProduct()
        {
            products = new List <Product>();

            ProductCollectionMoq.GetProductPriceByKey(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            double price = MockProductRepository.Object.GetProductPriceByKey(0);

            Assert.AreEqual(-1, price);
        }
        public void DecreaseProductQuantityWhenIdExists()
        {
            ProductCollectionMoq.DecreaseProductQuantity(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            MockProductRepository.Object.DecreaseProductQuantity(0);

            IList <Product> foundProducts   = MockProductRepository.Object.GetProducts();
            int             updatedQuantity = foundProducts.FirstOrDefault(product => product.ProductId == 0).Quantity;

            Assert.AreEqual(5, updatedQuantity);
        }
        public void AddProduct()
        {
            ProductCollectionMoq.AddProduct(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            Product p = new Product {
                ProductId = 0, Name = "ProdTest1a", Quantity = 4, Price = 10
            };

            MockProductRepository.Object.AddProduct(p);
            IList <Product> foundProducts = MockProductRepository.Object.GetProducts();

            Assert.AreEqual(foundProducts.Count, products.Count);
        }
        public void UpdateProduct()
        {
            ProductCollectionMoq.UpdateProduct(MockProductRepository, products);
            ProductCollectionMoq.GetProducts(MockProductRepository, products);

            Product p = new Product {
                ProductId = 0, Name = "ProdTest1a", Quantity = 4, Price = 10
            };

            MockProductRepository.Object.UpdateProduct(p);
            IList <Product> foundProducts = MockProductRepository.Object.GetProducts();

            string updatedName = foundProducts.FirstOrDefault(product => product.ProductId == p.ProductId).Name;

            Assert.AreEqual("ProdTest1a", updatedName);
        }