Beispiel #1
0
        public void AddToMenu_ShouldGetCorrectBoolean()
        {
            Menu           content     = new Menu();
            MenuItem       menuContent = new MenuItem();
            CafeRepository repository  = new CafeRepository();

            bool addResult = repository.AddMenuItems(menuContent);

            Assert.IsTrue(addResult);
        }
        //Create new menu item
        private void CreateNewItem()
        {
            Console.Clear();

            Cafe           newItem = new Cafe();
            CafeRepository menu    = new CafeRepository();

            //Meal Number

            Console.WriteLine("Please enter the item/meal number:");

            string input = Console.ReadLine();
            int    number;
            bool   isNumber = Int32.TryParse(input, out number);

            if (isNumber == true)
            {
                newItem.MealNumber = number;
            }
            else
            {
                Console.WriteLine("Please input a valid number\n" +
                                  "Press any key to continue");
                Console.ReadKey();
                CreateNewItem();
            }

            //Meal Name
            Console.WriteLine("Please enter the item/meal name:");
            string nameInput = Console.ReadLine().ToLower();

            if (nameInput != null)
            {
                newItem.MealName = nameInput;
            }
            else
            {
                Console.WriteLine("Please input a valid name\n" +
                                  "Press any key to continue");
                Console.ReadKey();
                CreateNewItem();
            }

            //Meal Description
            Console.WriteLine("Please enter the item/meal description:");
            newItem.Description = Console.ReadLine().ToLower();
            //Meal Ingredients
            Console.WriteLine("Please enter the item/meal ingredients:");
            string ingredients = Console.ReadLine();

            newItem.AddIngredients(ingredients);
            //Meal Price
            Console.WriteLine("Please enter the item/meal price:");

            string priceInput = Console.ReadLine();

            double priceNumber;
            bool   isItNumber = double.TryParse(priceInput, out priceNumber);

            if (isItNumber == true)
            {
                newItem.Price = priceNumber;
            }
            else
            {
                Console.WriteLine("Please input a valid number\n" +
                                  "Press any key to continue");
                Console.ReadKey();
            }
            _menuRepo.AddMenuItems(newItem);

            Menu();
        }