Пример #1
0
        private void DeleteContent()
        {
            Console.Clear();
            Console.WriteLine("Please type in title to delete: ");

            //iterate titles
            List <StreamingContentBase> listOfContents = _repo.GetContents();

            foreach (StreamingContentBase contentTitle in listOfContents)
            {
                Console.WriteLine($"- {contentTitle.Title}");
            }

            string title = Console.ReadLine();
            StreamingContentBase content = _repo.GetContentByTitle(title);

            bool contentDidDelete = _repo.DeleteExisitingContent(content);

            if (contentDidDelete != false)
            {
                Console.WriteLine("Content successfully deleted");
            }
            else
            {
                Console.WriteLine("Something went wrong. Was not able to delete content");
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
Пример #2
0
        public void AddToDirectory_ShouldGetCorrectBoolean()
        {
            StreamingContentBase content    = new StreamingContentBase();
            StreamingContentRepo repository = new StreamingContentRepo();

            bool addResult = repository.AddContentToDirectory(content);

            Assert.IsTrue(addResult);
        }
Пример #3
0
        public void CheckIfFamilyFriendlyBasedOnMaturityRating()
        {
            StreamingContentBase isFamilyFriendly = new StreamingContentBase();

            isFamilyFriendly.MaturityRating = MaturityRating.R;
            bool check = isFamilyFriendly.IsFamilyFriendly;

            Assert.IsFalse(check);
        }
Пример #4
0
        public void SetTitle_ShouldReturnCorrectString()
        {
            //Arrange
            StreamingContentBase var1 = new StreamingContentBase();

            //Act
            var1.Title = "Movie 2";

            //Assert
            Assert.AreEqual(var1.Title, "Movie 2");
        }
Пример #5
0
        public void GetDirectory_ShouldReturnCorrectCollection()
        {
            StreamingContentBase content = new StreamingContentBase();
            StreamingContentRepo repo    = new StreamingContentRepo();

            repo.AddContentToDirectory(content);

            List <StreamingContentBase> contents = repo.GetContents();

            bool directoryHasContent = contents.Contains(content);

            //Assert
            Assert.IsTrue(directoryHasContent);
        }
Пример #6
0
        private void DisplayContent(StreamingContentBase content)
        {
            //Display Content
            int    multiplier = 20;
            string division   = String.Concat(Enumerable.Repeat("*", multiplier));

            Console.WriteLine(division);
            Console.WriteLine($"Title: {content.Title}");
            Console.WriteLine($"Description: {content.Description}");
            Console.WriteLine($"Star-rating: {content.StarRating}");
            Console.WriteLine($"Genre: {content.Genre}");
            Console.WriteLine($"Maturity Rating: {content.MaturityRating}");
            Console.WriteLine($"Is family friendly?: {content.IsFamilyFriendly}");
            Console.WriteLine(division);
        }
Пример #7
0
        public void DeleteContent_ShouldDeleteContentCorrectly()
        {
            //Arrange
            StreamingContentRepo repo            = new StreamingContentRepo();
            StreamingContentBase existingContent = new StreamingContentBase("Jumanji", "Cool", 10, Genre.Action, MaturityRating.PG_13);

            repo.AddContentToDirectory(existingContent);

            //Act
            StreamingContentBase content = repo.GetContentByTitle("Jumanji");
            bool didDelete = repo.DeleteExisitingContent(content);

            //Assert
            Assert.IsTrue(didDelete);
        }
Пример #8
0
        public void GetByTitle_ShouldReturnCorrectContent()
        {
            //Arrange
            StreamingContentRepo repo       = new StreamingContentRepo();
            StreamingContentBase newContent = new StreamingContentBase("Jumanji", "Cool", 10, Genre.Action, MaturityRating.PG_13);

            repo.AddContentToDirectory(newContent);
            string title = "Jumanji";

            //Act
            StreamingContentBase searchResult = repo.GetContentByTitle(title);

            //Assert
            Assert.AreEqual(searchResult.Title, title);
        }
Пример #9
0
        public void UpdateContent_ShouldUpdateContentCorrectly()
        {
            //Arrange
            StreamingContentRepo repo       = new StreamingContentRepo();
            StreamingContentBase oldContent = new StreamingContentBase("Jumanji", "Cool", 10, Genre.Action, MaturityRating.PG_13);

            repo.AddContentToDirectory(oldContent);

            StreamingContentBase newContent = new StreamingContentBase("Jumanji", "It sucks", 7, Genre.Horror, MaturityRating.PG_13);

            //Act
            bool didUpdateContent = repo.UpdateExistingContent("Jumanji", newContent);

            //Assert
            Assert.IsTrue(didUpdateContent);
        }
Пример #10
0
        private void GetContentByTitle()
        {
            Console.Clear();

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

            StreamingContentBase content = _repo.GetContentByTitle(title);

            if (content != null)
            {
                DisplayContent(content);
            }
            else
            {
                Console.WriteLine("That title doesn't exist.");
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
Пример #11
0
        private void SeedContent()
        {
            StreamingContentBase futureWar = new StreamingContentBase(
                "Future War",
                "A war in the future",
                10.0,
                Genre.SciFi,
                MaturityRating.G
                );

            _repo.AddContentToDirectory(futureWar);

            StreamingContentBase theRoom = new StreamingContentBase(
                "The Room",
                "Everyone betrays Johnny",
                10.0,
                Genre.Documentary,
                MaturityRating.G
                );

            _repo.AddContentToDirectory(theRoom);
        }
Пример #12
0
        private void UpdateExistingContent()
        {
            Console.Clear();

            Console.WriteLine("Please enter title of content you would like to update: ");
            string title = Console.ReadLine();

            //StreamingContentBase contentToUpdate = _repo.GetContentByTitle(title);

            if (title != null)
            {
                //instantiate empty StreamingContentBase object
                StreamingContentBase newContent = new StreamingContentBase();

                //get user input
                Console.WriteLine("Enter a title:");
                newContent.Title = Console.ReadLine();

                Console.WriteLine("Enter a description:");
                newContent.Description = Console.ReadLine();

                Console.WriteLine("Enter a rating (1.0 - 10.0):");
                string ratingAsString = Console.ReadLine();
                double ratingAsDouble = double.Parse(ratingAsString);
                newContent.StarRating = ratingAsDouble;

                Console.WriteLine("Select a genre:");
                Console.WriteLine(" 1.Horror\n 2.RomCom\n 3.SciFi\n 4.Action\n 5.Documentary\n 6.Musical\n" +
                                  " 7.Drama\n 8.Mystery\n");
                string genreInput = Console.ReadLine();
                int    genreInt   = Int32.Parse(genreInput);
                //cast the genre
                newContent.Genre = (Genre)(genreInt - 1);

                Console.WriteLine("Select a Maturity Rating:");
                Console.WriteLine(" 1.G\n 2.PG\n 3.PG_13\n 4.R\n 5.NC_17\n");

                string maturityRating = Console.ReadLine();

                switch (maturityRating)
                {
                case "1":
                    newContent.MaturityRating = MaturityRating.G;
                    break;

                case "2":
                    newContent.MaturityRating = MaturityRating.PG;
                    break;

                case "3":
                    newContent.MaturityRating = MaturityRating.PG_13;
                    break;

                case "4":
                    newContent.MaturityRating = MaturityRating.R;
                    break;

                case "5":
                    newContent.MaturityRating = MaturityRating.NC_17;
                    break;

                default:
                    throw new InvalidEnumArgumentException("Invalid selection from category");
                }

                bool wasUpdated = _repo.UpdateExistingContent(title, newContent);

                if (wasUpdated)
                {
                    Console.WriteLine("Content successfully updated!");
                }
                else
                {
                    Console.WriteLine("ERROR: Content not added.");
                }
            }
            else
            {
                Console.WriteLine("Title doesn't exist");
            }
        }
Пример #13
0
        private void CreateNewContent()
        {
            Console.Clear();

            //instantiate empty StreamingContentBase object
            StreamingContentBase newContent = new StreamingContentBase();

            //get user input
            Console.WriteLine("Enter a title:");
            newContent.Title = Console.ReadLine();

            Console.WriteLine("Enter a description:");
            newContent.Description = Console.ReadLine();

            Console.WriteLine("Enter a rating (1.0 - 10.0):");
            string ratingAsString = Console.ReadLine();
            double ratingAsDouble = double.Parse(ratingAsString);

            newContent.StarRating = ratingAsDouble;

            Console.WriteLine("Select a genre:");
            Console.WriteLine(" 1.Horror\n 2.RomCom\n 3.SciFi\n 4.Action\n 5.Documentary\n 6.Musical\n" +
                              " 7.Drama\n 8.Mystery\n");
            string genreInput = Console.ReadLine();
            int    genreInt   = Int32.Parse(genreInput);

            //cast the genre
            newContent.Genre = (Genre)(genreInt - 1);

            Console.WriteLine("Select a Maturity Rating:");
            Console.WriteLine("1.G\n 2.PG\n 3.PG_13\n 4.R\n 5.NC_17\n");

            string maturityRating = Console.ReadLine();

            switch (maturityRating)
            {
            case "1":
                newContent.MaturityRating = MaturityRating.G;
                break;

            case "2":
                newContent.MaturityRating = MaturityRating.PG;
                break;

            case "3":
                newContent.MaturityRating = MaturityRating.PG_13;
                break;

            case "4":
                newContent.MaturityRating = MaturityRating.R;
                break;

            case "5":
                newContent.MaturityRating = MaturityRating.NC_17;
                break;

            default:
                throw new InvalidEnumArgumentException("Invalid selection from category");
            }

            bool wasAdded = _repo.AddContentToDirectory(newContent);

            if (wasAdded)
            {
                Console.WriteLine("Content successfully added");
            }
            else
            {
                Console.WriteLine("Oops! Something went wrong, not added.");
            }

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }