Example #1
0
        public void FindByTitle_ShouldGetCorrectContent()
        {
            //Arrange
            // Act
            StreamingContent searchResult = _repo.GetContentByTitle("Groundhog Day");

            // Assert
            Assert.AreEqual(searchResult, _content);
        }
Example #2
0
        private void UpdateExistingContent()
        {
            // Finish this method
            Console.Clear();
            Console.WriteLine("Enter the title of the content you'd like to update.");
            string           title   = Console.ReadLine();
            StreamingContent oldItem = _repo.GetContentByTitle(title);

            if (oldItem == null)
            {
                Console.WriteLine("Content not found, press any key to continue...");
                Console.ReadKey();
                return;
            }

            StreamingContent newItem = new StreamingContent(
                oldItem.Title,
                oldItem.Description,
                oldItem.StarRating,
                oldItem.Genre,
                oldItem.MaturityRating
                );

            Console.WriteLine("Which property would you like to update:\n" +
                              "1. Title\n" +
                              "2. Description\n" +
                              "3. Star Rating\n" +
                              "4. Maturity Rating\n" +
                              "5. Genre\n" +
                              "6. Nevermind");

            string selection = Console.ReadLine();

            switch (selection)
            {
            case "1":
                Console.WriteLine("Enter a new title");
                string newTitle = Console.ReadLine();
                newItem.Title = newTitle;

                bool wasSuccessful = _repo.UpdateExistingContent(title, newItem);

                if (wasSuccessful)
                {
                    Console.WriteLine("Item successfully updated");
                }
                else
                {
                    Console.WriteLine($"Error: Could not update {title}");
                }
                break;

            default:
                break;
            }
        }
Example #3
0
        private void ShowAllContentByTitle()
        {
            // DRY= Don't Repeat Yourself
            string title = GetTitleFromUser();

            StreamingContent content = _repo.GetContentByTitle(title);

            if (content != null)
            {
                DisplayContent(content);
            }
            else
            {
                Console.WriteLine("Invalid title. Could not find any results.");
            }

            Console.ReadKey();
        }
Example #4
0
        private void ShowContentByTitle()
        {
            Console.Clear();

            Console.WriteLine("Enter the title of the content you'd like to see.");
            string title = Console.ReadLine();

            StreamingContent content = _repo.GetContentByTitle(title);

            if (content != null)
            {
                DisplayContent(content);
            }
            else
            {
                Console.WriteLine("That title doesn't exist.");
            }
            Console.ReadKey();
        }
Example #5
0
        private void ShowContentByTitle()
        {
            Console.Clear();
            Console.WriteLine("Enter the title of the content you'd like to see.");
            string title = Console.ReadLine();

            StreamingContent content = _repo.GetContentByTitle(title);

            if (content != null)
            {
                DisplayContent(content);
                Console.WriteLine("Press any key to continue.");
            }
            else
            {
                Console.WriteLine("Title not found. Press and key to continue.");
            }
            Console.ReadKey();
        }
Example #6
0
        public void GetByTitle_ShouldReturnCorrectConents()
        {
            //Arrange
            StreamingContent_Repo repo       = new StreamingContent_Repo();
            StreamingContent      newContent = new StreamingContent("Toy Story", "Toys come to life", 10, Genre.Action, MaturityRating.G);

            repo.AddContentToDirectory(newContent);
            string title = "Toy Story";

            //ACT
            StreamingContent searchResult = repo.GetContentByTitle(title);

            //Assert
            Assert.AreEqual(searchResult.Title, title);
        }
Example #7
0
        public void DeleteExistingContent_ShouldReturnTrue()
        {
            //Arrange
            StreamingContent_Repo repo    = new StreamingContent_Repo();
            StreamingContent      content = new StreamingContent("Toy Story", "Toys come to life", 8, Genre.Drama, MaturityRating.PG);

            repo.AddContentToDirectory(content);

            //Act
            StreamingContent oldContent = repo.GetContentByTitle("Toy Story");

            bool removeResult = repo.DeleteExistingContent(oldContent);

            //Assert
            Assert.IsTrue(removeResult);
        }
Example #8
0
        private void UpdateExistingContent()
        {
            Console.Clear();

            //ShowContentByTitle();
            Console.WriteLine("Select the title of the content you'd like to update.");
            string           title   = Console.ReadLine();
            StreamingContent oldItem = _repo.GetContentByTitle(title);

            if (oldItem == null)
            {
                Console.WriteLine("Content not found, Press any key to continue...");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("What property would you like to update in it?");
            Console.WriteLine("1. Title");
            Console.WriteLine("2. Description");
            Console.WriteLine("3. Star Rating");
            Console.WriteLine("4. Genre");
            Console.WriteLine("5. Maturity Rating");

            string updateInput = Console.ReadLine();

            switch (updateInput)
            {
            case "1":
                Console.WriteLine("Please enter the new title");
                oldItem.Title = Console.ReadLine();
                break;

            case "2":
                Console.WriteLine("Please enter the new description");
                oldItem.Description = Console.ReadLine();
                break;

            case "3":
                Console.WriteLine("Please enter the new Star Rating");
                oldItem.StarRating = Convert.ToDouble(Console.ReadLine());
                break;

            case "4":
                Console.WriteLine("Please enter the new Genre");

                Console.WriteLine("Select a genre. ");
                Console.WriteLine("1.Horror");
                Console.WriteLine("2.RomCom");
                Console.WriteLine("3.SciFi");
                Console.WriteLine("4.Action");
                Console.WriteLine("5.Documentary");
                Console.WriteLine("6.Musical");
                Console.WriteLine("7.Drama");
                Console.WriteLine("8.Mystery");

                string genreThingy = Console.ReadLine();
                int    genreThing  = int.Parse(genreThingy); //parsing
                oldItem.Genre = (Genre)genreThing;           //casting

                break;

            //case "5":
            //    Console.WriteLine("Please enter the new Maturity Rating");
            //    oldItem.MaturityRating = Console.ReadLine();
            //    break;
            default:
                Console.WriteLine("Please enter a value.");
                break;
            }
        }
Example #9
0
        private void UpdateExistingContent()
        {
            Console.Clear();

            Console.WriteLine("Enter the title you want to update.");
            string           title   = Console.ReadLine();
            StreamingContent oldItem = _repo.GetContentByTitle(title);

            if (oldItem == null)
            {
                Console.WriteLine("Content not found, press any key to continue");
                Console.ReadKey();
                return;
            }

            StreamingContent newItem = new StreamingContent(
                oldItem.Title,
                oldItem.Description,
                oldItem.StarRating,
                oldItem.Genre,
                oldItem.MaturityRating
                );

            Console.Clear();

            DisplayContent(oldItem);
            Console.WriteLine("Select what you would like to update.");
            Console.WriteLine("1. Title");
            Console.WriteLine("2. Description");
            Console.WriteLine("3. Star Rating");
            Console.WriteLine("4. Genre");
            Console.WriteLine("5. Maturity Rating");
            Console.WriteLine("6. Never mind");

            string selection = Console.ReadLine();

            switch (selection)
            {
            case "1":
                Console.WriteLine("Please enter the new title.");
                string newTitle = Console.ReadLine();
                newItem.Title = newTitle;

                bool wasSuccessful = _repo.UpdateExistingContent(title, oldItem);
                if (wasSuccessful)
                {
                    Console.WriteLine("Item successfully updated");
                }
                else
                {
                    Console.WriteLine($"Error: Could not update {title}");
                }
                break;

            default:
                break;
            }


            //Console.ReadKey();
        }