public async Task findProductsuccess() { ProductData p = new ProductData(new Guid(), "soy milk", 8, 50, 500, "vegan"); Store s = store = await market.CreateStore("Vegan store12", "founder", null, null); Result <Product> result1 = await MarketStores.Instance.AddProduct(p, store.Id, "founder"); ProductData p2 = new ProductData(new Guid(), "soy milk diff", 8, 50, 500, "vegan"); Store s2 = await market.CreateStore("vegan store 2", "founder", null, null); Result <Product> result2 = await MarketStores.Instance.AddProduct(p2, store.Id, "founder"); ICollection <Product> ret = await market.findProducts("soy milk", -1, -1, -1, "vegan"); Assert.IsTrue(ret.Contains(result1.Ret) && ret.Contains(result2.Ret)); }
public async Task findProductsuccess() { Product p = new Product(new Guid(), "soy milk", 8, 50, 500, "vegan"); Store s = new Store("vegan store", null, null); s.Products.Add(p); await marketStores.addToCategory(p, "vegan"); marketStores.LoadedStores.TryAdd(s.GetId(), s); Product p2 = new Product(new Guid(), "soy milk diff", 8, 50, 500, "vegan"); Store s2 = new Store("vegan store 2", null, null); s2.Products.Add(p2); await marketStores.addToCategory(p2, "vegan"); marketStores.LoadedStores.TryAdd(s2.GetId(), s2); ICollection <Product> ret = await marketStores.findProducts("soy milk", -1, -1, -1, "vegan"); Assert.IsTrue(ret.Contains(p) && ret.Contains(p2)); }
public async Task <ICollection <ProductData> > FindProducts(string keyword, int price_range_low, int price_range_high, int rating, string category) { if (string.IsNullOrWhiteSpace(keyword)) { return(new ProductData[] { }); } ICollection <Product> pro = await marketStores.findProducts(keyword, price_range_low, price_range_high, rating, category); ICollection <ProductData> products = new LinkedList <ProductData>(); foreach (Product p in pro) { products.Add(new ProductData(p)); } return(products); }