public void SetUpContextAndDbSet()
        {
            //Mock DbSet<ShoppingCartProduct> to return data when called
            //Create a test ShoppingCartProduct to be Assigned to Product Two
            var testShoppingCartProduct = new ShoppingCartProduct { Id = 1, ProductId = 2, ShoppingCartId = 1, Quantity = 1 };

            //Set up a shopping cart product dataset
            var shoppingCartData = new List<ShoppingCartProduct>() {
                testShoppingCartProduct
            }.AsQueryable();

            mockShoppingCartProductSet = new Mock<DbSet<ShoppingCartProduct>>();
            mockShoppingCartProductSet.As<IQueryable<ShoppingCartProduct>>().Setup(m => m.Provider).Returns(shoppingCartData.Provider);
            mockShoppingCartProductSet.As<IQueryable<ShoppingCartProduct>>().Setup(m => m.Expression).Returns(shoppingCartData.Expression);
            mockShoppingCartProductSet.As<IQueryable<ShoppingCartProduct>>().Setup(m => m.ElementType).Returns(shoppingCartData.ElementType);
            mockShoppingCartProductSet.As<IQueryable<ShoppingCartProduct>>().Setup(m => m.GetEnumerator()).Returns(shoppingCartData.GetEnumerator());

            //Create a test Product and assign it testShoppingCartProduct created eralier
            var productTwo = new Product { Id = 2, Name = "Product Two", PriceInEur = 1.00M };
            productTwo.ShoppingCartProducts = new List<ShoppingCartProduct>();
            productTwo.ShoppingCartProducts.Add(testShoppingCartProduct);

            testShoppingCartProduct.Product = new Product();
            testShoppingCartProduct.Product = productTwo;
            
            //Set up product dataset
            var productData = new List<Product>
            {
                new Product { Id = 1, Name = "Product One", PriceInEur = 10.00M },
                productTwo,
                new Product { Id = 3, Name = "Product Three", PriceInEur = 8.00M },
                new Product { Id = 4, Name = "Product Four", PriceInEur = 2.00M },
            }.AsQueryable();

            //Mock the DbSet and set up it configurations
            mockProductSet = new Mock<DbSet<Product>>();
            mockProductSet.As<IQueryable<Product>>().Setup(m => m.Provider).Returns(productData.Provider);
            mockProductSet.As<IQueryable<Product>>().Setup(m => m.Expression).Returns(productData.Expression);
            mockProductSet.As<IQueryable<Product>>().Setup(m => m.ElementType).Returns(productData.ElementType);
            mockProductSet.As<IQueryable<Product>>().Setup(m => m.GetEnumerator()).Returns(productData.GetEnumerator());

            //Mock the database context
            this.mockContext = new Mock<ShoppingCartContext>();
            this.mockContext.Setup(c => c.Products).Returns(mockProductSet.Object);
            this.mockContext.Setup(c => c.ShoppingCartProducts).Returns(mockShoppingCartProductSet.Object);
        }
        public ShoppingCartProductResponse AddShoppingCartProduct(ShoppingCartProductRequest request)
        {
            ShoppingCartProductResponse response = new ShoppingCartProductResponse();

            try
            {
                ShoppingCartProduct dbShoppingCartProduct = shoppingCartProductRepository.FindShoppingCartProduct(this.shoppingCartId, request.ProductId);

                //If entry exists, update existing
                if (dbShoppingCartProduct != null)
                {
                    dbShoppingCartProduct.Quantity += request.Quantity;                    
                }
                //Else create a new one. Skip if quantity is set to zero.
                else if(request.Quantity != 0)
                {
                    ShoppingCartProduct newShoppingCartProduct = new ShoppingCartProduct()
                    {
                        ProductId = request.ProductId
                        ,ShoppingCartId = this.shoppingCartId
                        ,Quantity = request.Quantity
                    };

                    shoppingCartProductRepository.Add(newShoppingCartProduct);
                }

                shoppingCartProductRepository.Commit();
            }
            catch (Exception ex)
            {

                response.Exception = ex;
            }

            return response;
        }