コード例 #1
0
        private void CreateNewItem()
        {
            Console.Clear();
            MenuPoco newItem = new MenuPoco();

            Console.WriteLine("Enter the item's name:");
            newItem.MealName = Console.ReadLine();

            Console.WriteLine("Enter the item's number:");
            string mealNumberAsString = Console.ReadLine();

            newItem.MealNumber = int.Parse(mealNumberAsString);

            Console.WriteLine("Enter the item's description:");
            newItem.MealDescription = Console.ReadLine();

            Console.WriteLine("Enter the item's list of ingredients:");
            newItem.IngredientsList = Console.ReadLine();

            Console.WriteLine("Enter the item's price:");
            string mealPriceAsString = Console.ReadLine();

            newItem.MealPrice = double.Parse(mealPriceAsString);

            _itemRepo.AddItemToList(newItem);
        }
コード例 #2
0
        public void GetThisPartyStarted()
        {
            _repo = new MenuRepo();
            _item = new MenuPoco(1, "Pig's feet", "Braised with pig's blood, and served with a side of roasted pig testicles and boiled intestines, it's sure to delight!", "Feet, eyes, intestines", 11.50);

            _repo.AddItemToList(_item);
        }
コード例 #3
0
        public void UpdateItem_ShouldReturnTrue()
        {
            //Arrange  ...(Test Init)
            MenuPoco newItem = new MenuPoco(1, "Pig's feet", "Braised with pig's blood, and served with a side of toasted pig eyeballs (seasonal), it's sure to delight!", "ingredients", 11.50);

            //Act
            bool updateOutput = _repo.UpdateItemList("Pig's feet", newItem);

            //Assert
            Assert.IsTrue(updateOutput);
        }
コード例 #4
0
        public void AddToList_ShouldGetNotNull()
        {
            //Arrange
            MenuPoco item = new MenuPoco();                                             //new up

            item.MealName = "Anchovie Icecream";                                        //set
            MenuRepo repo = new MenuRepo();                                             //new up

            //Act
            repo.AddItemToList(item);                                                   //add
            MenuPoco itemFromDirectory = repo.GetItemByName("Anchovie Icecream");       //get

            //Assert
            Assert.IsNotNull(itemFromDirectory);                                        //verify
        }
コード例 #5
0
        private void UpdateExistingItems()
        {
            ViewAllItems();

            Console.WriteLine("Please give the name of the meal to update");

            string oldName = Console.ReadLine();

            MenuPoco newItem = new MenuPoco();

            Console.WriteLine("Enter the item's name:");
            newItem.MealName = Console.ReadLine();

            Console.WriteLine("Enter the item's number:");
            string mealNumberAsString = Console.ReadLine();

            newItem.MealNumber = int.Parse(mealNumberAsString);

            Console.WriteLine("Enter the item's description:");
            newItem.MealDescription = Console.ReadLine();

            Console.WriteLine("Enter the item's list of ingredients:");
            newItem.IngredientsList = Console.ReadLine();

            Console.WriteLine("Enter the item's price:");
            string mealPriceAsString = Console.ReadLine();

            newItem.MealPrice = double.Parse(mealPriceAsString);

            bool wasUpdated = _itemRepo.UpdateItemList(oldName, newItem);

            if (wasUpdated)
            {
                Console.WriteLine("Update successful!");
            }
            else
            {
                Console.WriteLine("Update was not successful...");
            }
        }
コード例 #6
0
        private void ViewItemByName()
        {
            Console.Clear();

            Console.WriteLine("Enter the name of the meal:");

            string name = Console.ReadLine();

            MenuPoco item = _itemRepo.GetItemByName(name);

            if (item != null)
            {
                Console.WriteLine($"Name: {item.MealName}\n" +
                                  $"Description: {item.MealDescription}\n" +
                                  $"Number: {item.MealNumber}\n" +
                                  $"Ingredients List: {item.IngredientsList}\n" +
                                  $"Price: {item.MealPrice}");
            }
            else
            {
                Console.WriteLine("No meal exists with that name");
            }
        }