Ejemplo n.º 1
0
        public void TestGetProducts()
        {
            int productId = 1;
            GetProductsResponse response = new GetProductsResponse();
            response.Products.Add(new ProductDTO() {Id = productId});

            Expect.Once.On(service).Method("GetProductsByCriteria").Will(Return.Value(response));
            IList<ProductDTO> products = serviceFacade.GetProductsByCategory("FakeCategory");
            Assert.AreEqual(1, products.Count);
            Assert.AreEqual(products.First().Id, productId);

            Expect.Once.On(service).Method("GetProductsByCriteria").Will(Return.Value(response));
            products = serviceFacade.GetProductsByName("FAkeName");
            Assert.AreEqual(1, products.Count);
            Assert.AreEqual(products.First().Id, productId);

            Expect.Once.On(service).Method("GetProductsByCriteria").Will(Return.Value(response));
            products = serviceFacade.GetAllProducts();
            Assert.AreEqual(1, products.Count);
            Assert.AreEqual(products.First().Id, productId);
        }
Ejemplo n.º 2
0
        public GetProductsResponse GetProductsByCriteria(GetProductsRequest request)
        {
            GetProductsResponse response = new GetProductsResponse();
            ProductBusinessComponent bc = DependencyInjectionHelper.GetProductBusinessComponent();

            IQueryable<Product> products = bc.GetProductsByCriteria(request.SearchType, request.Category, request.ProductName);
            response.Products = ProductAdapter.ProductsToDtos(products);

            return response;
        }
Ejemplo n.º 3
0
        public GetProductsResponse GetProductByCriteria(GetProductsRequest request)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                throw new FaultException<NotAuthenticatedFault>(new NotAuthenticatedFault());
            GetProductsResponse response = new GetProductsResponse();
            ProductBusinessComponent bc = DependencyInjectionHelper.GetProductBusinessComponent();

            IQueryable<Product> products = bc.GetProductsByCriteria(request.SearchType, request.Category, request.ProductName);
            response.Products = ProductAdapter.ProductsToDtos(products);

            return response;
        }