Ejemplo n.º 1
0
        public GetAllProductsResponse GetAllProducts()
        {
            GetAllProductsResponse response = new GetAllProductsResponse();

            try
            {
                IEnumerable<Product> dbProducts = productRepository.GetAll();

                foreach (Product dbProduct in dbProducts)
                {
                    response.ProductList.Add(new ProductDto
                    {
                        Id = dbProduct.Id
                        ,Name = dbProduct.Name
                        ,PriceInEur = dbProduct.PriceInEur
                    });
                }
            }
            catch (Exception ex)
            {
                response.Exception = ex;
            }

            return response;
        }
        public void SetUpServices()
        {
            getAllProductsResponse = new GetAllProductsResponse();
            getAllProductsResponse.ProductList = getAllTestProducts();

            findShoppingCartProductsResponse = new FindShoppingCartProductsResponse();
            findShoppingCartProductsResponse.ProductList = findTestShoppingCartProducts();

            productService = new Mock<IProductService>();
            productService.Setup(x => x.GetAllProducts()).Returns(getAllProductsResponse);
            productService.Setup(x => x.FindShoppingCartProducts()).Returns(findShoppingCartProductsResponse);
        }