public void SearchItems(string searchTerm)
        {
            ShopModel model = (ShopModel)Session["model"];

            Session["searchTerm"] = searchTerm;

            model.itemCatalog     = ItemCatalogFacilitator.GetAllItems(); // reset
            model.itemCatalog     = ItemCatalogFacilitator.SearchItems(searchTerm, model.itemCatalog);
            Session["fromSearch"] = true;
            Session["model"]      = model;
        }
Esempio n. 2
0
        public void SearchItemsTest()
        {
            List <Item> itemList = new List <Item>();
            Item        item1    = new Item
            {
                itemID       = 1,
                name         = "A",
                category     = "hello",
                description  = "bad no",
                sellingPrice = 25
            };
            Item item2 = new Item
            {
                itemID       = 2,
                name         = "B",
                category     = "djdjd",
                description  = "bad good fire",
                sellingPrice = 10
            };
            Item item3 = new Item
            {
                itemID       = 3,
                name         = "C",
                category     = "category",
                description  = "hello good fire",
                sellingPrice = 100
            };

            itemList.Add(item1);
            itemList.Add(item2);
            itemList.Add(item3);
            // going to search for word "hello"

            itemList = ItemCatalogFacilitator.SearchItems("hello", itemList);
            // item list should only have 2 items now
            if (itemList.Count != 2)
            {
                Assert.Fail();
            }
            // item list shouldn't contain item2
            if (itemList.Contains(item2))
            {
                Assert.Fail();
            }
        }