Ejemplo n.º 1
0
        public void GetMealListTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.AddMeal(model.FindMealByName("薯條(小包)"));
            Assert.AreEqual(model.GetMealList()[0].Name, "薯條(小包)");
        }
Ejemplo n.º 2
0
        public void GetCurrentPageTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            Assert.AreEqual(model.GetCurrentPage("漢堡"), "Page: 1/1");
            Assert.AreEqual(model.GetCurrentPage("找不到"), "");
        }
Ejemplo n.º 3
0
        public void IsAddButtonEnableTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            Assert.IsFalse(model.IsAddButtonEnable());
            model.AddMeal(model.FindMealByName("大麥克"));
            Assert.IsTrue(model.IsAddButtonEnable());
        }
Ejemplo n.º 4
0
        public void GetMealButtonVisibleTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            Assert.IsTrue(model.GetMealButtonVisible("漢堡", 0));
            Assert.IsFalse(model.GetMealButtonVisible("漢堡", 11));
            Assert.IsFalse(model.GetMealButtonVisible("找不到", 11));
        }
Ejemplo n.º 5
0
        public void GetTotalPriceTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.AddMeal(model.FindMealByName("薯條(小包)"));
            model.AddMeal(model.FindMealByName("薯條(中包)"));
            model.AddToDisplayMealList();
            Assert.AreEqual(model.GetTotalPrice(), 74);
        }
Ejemplo n.º 6
0
        public void ClearMealListTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.AddMeal(model.FindMealByName("薯條(小包)"));
            model.AddMeal(model.FindMealByName("薯條(中包)"));
            Assert.AreEqual(model.GetMealList().Count, 2);
            model.ClearMealList();
            Assert.AreEqual(model.GetMealList().Count, 0);
        }
Ejemplo n.º 7
0
        public void GetMealButtonLocationTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());
            List <int> buttonLocation           = model.GetMealButtonLocation(0);

            Assert.AreEqual(buttonLocation[0], 10);
            Assert.AreEqual(buttonLocation[1], 10);
            buttonLocation = model.GetMealButtonLocation(10);
            Assert.AreEqual(buttonLocation[0], 170);
            Assert.AreEqual(buttonLocation[1], 10);
        }
Ejemplo n.º 8
0
        public void AddOnePageTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.UpdateTotalPage(15, 0);
            model.AddOnePage("漢堡");
            PrivateObject        target        = new PrivateObject(model);
            List <CategoryState> categoryState = (List <CategoryState>)target.GetFieldOrProperty("_categoriesState");

            Assert.AreEqual(categoryState[0].CurrentPage, 2);
        }
Ejemplo n.º 9
0
        public void IsPreviousPageButtonEnableTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());
            PrivateObject        target         = new PrivateObject(model);
            List <CategoryState> categoryState  = (List <CategoryState>)target.GetFieldOrProperty("_categoriesState");

            categoryState[0].CurrentPage = 1;
            Assert.IsFalse(model.IsPreviousPageButtonEnable("漢堡"));
            categoryState[0].CurrentPage = 2;
            Assert.IsTrue(model.IsPreviousPageButtonEnable("漢堡"));
            Assert.IsFalse(model.IsPreviousPageButtonEnable("找不到"));
        }
Ejemplo n.º 10
0
        public void GetMenuTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());
            List <string> menuName = new List <string> {
                "大麥克", "雙層牛肉吉事堡", "安格斯黑牛堡", "嫩煎雞腿堡", "麥香雞", "麥克雞塊(6塊)", "麥克雞塊(9塊)", "勁辣雞腿堡", "麥脆雞(2塊)", "麥脆雞(3塊)", "黃金起司豬排堡", "麥香魚", "千島黃金蝦堡", "BLT 安格斯黑牛堡", "BLT 辣脆雞腿堡", "薯條(小包)", "薯條(中包)", "薯條(大包)", "薯餅", "蘋果派", "水果袋", "可口可樂(大)", "雪碧(大)", "冰紅茶(大)", "冰綠茶(大)", "冰奶茶(大)", "柳橙汁(大)"
            };
            List <Meal> menu = model.GetMenu();

            for (int i = 0; i < menu.Count; i++)
            {
                Assert.AreEqual(menu[i].Name, menuName[i]);
            }
        }
Ejemplo n.º 11
0
        public void GetCategoriesTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());
            List <string> categoryName          = new List <string> {
                "漢堡", "點心", "飲料"
            };
            List <string> categories = model.GetCategories();

            for (int i = 0; i < categories.Count; i++)
            {
                Assert.AreEqual(categories[i], categoryName[i]);
            }
        }
Ejemplo n.º 12
0
        public void DeleteFromDisplayMealListTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.AddMeal(model.FindMealByName("薯條(小包)"));
            model.AddMeal(model.FindMealByName("薯條(中包)"));
            model.AddToDisplayMealList();
            Assert.AreEqual(model.GetDisplayMealList().Count, 2);
            model.DeleteFromDisplayMealList("薯條(小包)");
            Assert.AreEqual(model.GetDisplayMealList().Count, 1);
            model.DeleteFromDisplayMealList("薯條(中包)");
            Assert.AreEqual(model.GetDisplayMealList().Count, 0);
        }
Ejemplo n.º 13
0
        public void GetMealButtonCategoryIndexTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            Assert.AreEqual(model.GetMealButtonCategoryIndex(model.FindMealByName("大麥克")), 0);
        }
Ejemplo n.º 14
0
        public void NotifyCategoryChangedObserverTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            model.NotifyCategoryChangedObserver();
        }
Ejemplo n.º 15
0
        public void FindMealByNameTest()
        {
            CustomerFormPresentationModel model = new CustomerFormPresentationModel(new Model());

            Assert.AreEqual("大麥克", model.FindMealByName("大麥克").Name);
        }