예제 #1
0
        private void DeleteExistingContent()
        {
            Console.Clear();
            Console.Write("Please choose the item you'd like to remove: \n");
            List <KomodoCafeContent> contentList = _kcRepo.GetAllContent();

            int count = 0;

            foreach (KomodoCafeContent content in contentList)
            {
                count++;
                Console.Write($"{count} - {content.MealName} \n");
            }
            int targetContentID = int.Parse(Console.ReadLine());
            int targetIndex     = targetContentID - 1;

            if (targetIndex >= 0 && targetIndex < contentList.Count)
            {
                KomodoCafeContent desiredContent = contentList[targetIndex];
                if (_kcRepo.DeleteExistingContent(desiredContent))
                {
                    Console.Write($"{desiredContent.MealName} has been removed ");
                }
                else
                {
                    Console.Write("Sorry, but you can't do that ");
                }
            }
            else
            {
                Console.Write("There has been an error, please try again \n" +
                              "Please press any key to continue");
                Console.ReadKey();
            }
        }
예제 #2
0
        public void GetAllDirectory_ShouldReturnCorrectList()
        {
            KomodoCafeContent testContent = new KomodoCafeContent();
            KomodoCafeRepo    repo        = new KomodoCafeRepo();

            repo.AddContentToDirectory(testContent);

            List <KomodoCafeContent> testList = repo.GetAllContent();
            bool directoryHasContent          = testList.Contains(testContent);

            Assert.IsTrue(directoryHasContent);
        }