Ejemplo n.º 1
0
        public void AddDishInverseOrder()
        {
            int index;
            DishList list = new DishList();
            Assert.AreEqual(0, list.Count, "List count is incorrect");

            list.Add(nightDishList[4]);
            Assert.AreEqual(4, list.Count, "List count is incorrect");
            list.Add(nightDishList[3]);
            Assert.AreEqual(4, list.Count, "List count is incorrect");
            list.Add(nightDishList[2]);
            Assert.AreEqual(4, list.Count, "List count is incorrect");
            list.Add(nightDishList[1]);
            Assert.AreEqual(4, list.Count, "List count is incorrect");

            for (index = 1; index <= 4; index++)
            {
                Assert.AreEqual(list[index], nightDishList[index]);
                Assert.IsTrue(list.Contains(nightDishList[index]));
            }
        }
Ejemplo n.º 2
0
        public void AccessingNonExistingItemOnList()
        {
            int code;
            DishList list = new DishList();

            list.Add(nightDishList[1]);
            list.Add(nightDishList[2]);
            list.Add(nightDishList[4]);

            Assert.IsNotNull(list[1]);
            Assert.IsNotNull(list[2]);
            Assert.IsNull(list[3]);
            Assert.IsNotNull(list[4]);
            
            code = 1;
            foreach (Dish dish in list)
            {
                if (code == 3)
                {
                    Assert.IsNull(dish);
                    Assert.IsFalse(list.Contains(dish));
                }
                else
                {
                    Assert.IsNotNull(dish);
                    Assert.IsTrue(list.Contains(dish));
                    Assert.AreEqual(code, dish.Code, "Incorrect index");
                }
                code++;
            }
        }