コード例 #1
0
        private void CreateNewMeal()
        {
            Console.Clear();
            MealContent newMeal = new MealContent();

            Console.WriteLine("Please enter the meal number:");
            string mealAsString = Console.ReadLine();

            newMeal.MealNumber = int.Parse(mealAsString);

            Console.WriteLine("Please enter the meal name:");
            newMeal.MealName = Console.ReadLine();

            Console.WriteLine("Please enter the meals description:");
            newMeal.MealDescription = Console.ReadLine();

            Console.WriteLine("What's the meals price?");
            string priceAsString = Console.ReadLine();

            newMeal.Price = double.Parse(priceAsString);

            Console.WriteLine("Which type of meal are you adding?\n" +
                              "1) Breakfast\n" +
                              "2) Lunch\n" +
                              "3) Dinner");

            string todAsString = Console.ReadLine();
            int    todAsInt    = int.Parse(todAsString);

            newMeal.TypeOfMeal = (MealType)todAsInt;

            _mealContentRepo.AddMealToMenuList(newMeal);
        }
コード例 #2
0
        public void TestForGetMealByNum2()
        {
            MealContentRepo mealTestRepo = new MealContentRepo();           //Extra test
            MealContent     mealTestCont = new MealContent();

            mealTestRepo.AddMealToMenuList(mealTestCont);

            //Act
            MealContent mealByNum = mealTestRepo.GetMealByMealNumber(mealTestCont.MealNumber);

            bool menuNumsAreEqual = mealTestCont.MealName == mealByNum.MealName;

            Assert.IsTrue(menuNumsAreEqual);
        }
コード例 #3
0
        public void TestForGetMealByNum()
        {
            //Arrange
            MealContentRepo repo = new MealContentRepo();
            MealContent     meal = new MealContent(5, "Turkey Breakfast", "Toast, turkey sausage, egg whites, wheat toast, and Milk.", 9, MealType.Breakfast);

            repo.AddMealToMenuList(meal);

            //Act
            MealContent mealByNum = repo.GetMealByMealNumber(meal.MealNumber);

            //Assert
            Assert.AreEqual(meal, mealByNum);
        }
コード例 #4
0
        public void AddToMenu_ShouldGetNotNull()
        {
            // Arrange = Setting up the playing field
            MealContentRepo repo = new MealContentRepo();
            MealContent     meal = new MealContent(5, "Turkey Breakfast", "Toast, turkey sausage, egg whites, wheat toast, and Milk.", 9, MealType.Breakfast);

            // Act = Get/run the code we want to test
            repo.AddMealToMenuList(meal);

            // Assert = Use the assert class to verify the expected outcome
            List <MealContent> listOfMeals = repo.GetMenuList();

            bool menuNumEqual = false;

            foreach (MealContent food in listOfMeals)
            {
                if (food.MealNumber == meal.MealNumber)
                {
                    menuNumEqual = true;
                    break;
                }
            }
            Assert.IsTrue(menuNumEqual);
        }