Ejemplo n.º 1
0
        public HttpResponseMessage Get()
        {
            try
            {
                List <ProductModel> products = productData.GetProducts();

                return(Request.CreateResponse(HttpStatusCode.OK, products));
            }
            catch (Exception e) {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, e.Message));
            }
        }
Ejemplo n.º 2
0
        public void GetProducts()
        {
            ProductsData controller = new ProductsData();

            List <WarehouseModel> warehouseList = new List <WarehouseModel>();

            warehouseList.Add(new WarehouseModel("SP", 5, "WEB"));
            warehouseList.Add(new WarehouseModel("SP", 5, "WEB"));
            controller.Add(new ProductModel(1, "teste", new InventoryModel(warehouseList)));
            controller.Add(new ProductModel(2, "outro", new InventoryModel(warehouseList)));

            List <ProductModel> result = controller.GetProducts();

            Assert.IsNotNull(result);
            Assert.AreEqual(2, result.Count);
        }