Exemple #1
0
        private void ShowByTitle()
        {
            _console.Clear();
            _console.WriteLine("Please enter a title: ");
            string           title        = _console.ReadLine();
            StreamingContent foundContent = _streamingRepo.GetContentByTitle(title);

            if (foundContent != null)
            {
                DisplayContent(foundContent);
            }
            else
            {
                _console.WriteLine("Invalid title. Could not find any results");
            }
            _console.WriteLine("Press any key to continue");
            _console.ReadKey();
        }
Exemple #2
0
        private void DeleteContentByTitle()
        {
            ShowAllContent();
            Console.WriteLine("Enter the title for the content you would like to delete.");
            string titleToDelete = Console.ReadLine();

            StreamingContent contentToDelete = _repo.GetContentByTitle(titleToDelete);
            bool             wasDeleted      = _repo.DeleteExistingContent(contentToDelete);

            if (wasDeleted)
            {
                Console.WriteLine("This content was successfully deleted.");
            }
            else
            {
                Console.WriteLine("Content could not be deleted");
            }
        }
Exemple #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();
        }
        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();
        }
Exemple #5
0
        //Update
        public bool UpdateExistingContent(string originalID, StreamingContent newContent)
        {
            StreamingContent oldContent = GetContentByTitle(originalTitle);

            if (oldContent != null)
            {
                oldContent.Title         = newContent.Title;
                oldContent.Description   = newContent.Description;
                oldContent.StarRating    = newContent.StarRating;
                oldContent.MaturityRatin = newContent.MaturityRatin;
                oldContent.TypeOfGenre   = newContent.TypeOfGenre;

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void GetDirectory_ShouldReturnCorrectCollection()
        {
            // Arrange

            StreamingContent           newObject = new StreamingContent();
            StreamingContentRepository repo      = new StreamingContentRepository();

            repo.AddContenttoDirectory(newObject);

            //ACT

            List <StreamingContent> listOfContents = repo.GetContents();

            // ASSERT

            bool directoryHasContent = listOfContents.Contains(newObject);

            Assert.IsTrue(directoryHasContent);
        }
Exemple #7
0
        //method that prompts user for which streamingContent object they want to delete
        //remove it from the _contentDirectory.

        //Bonus: Display all the options fro them to select from


        private void DeleteContentByTitle()
        {
            Console.Clear();

            ShowAllContent();
            Console.WriteLine("What would you like to delete?");
            string           title           = Console.ReadLine();
            StreamingContent contentToDelete = _repo.GetContentByTitle(title);
            bool             wasDeleted      = _repo.DeleteExistingContent(contentToDelete);

            if (wasDeleted)
            {
                Console.WriteLine("This content was deleted.");
            }
            else
            {
                Console.WriteLine("Content could not be deleted.");
            }
        }
Exemple #8
0
        public void UpdateContent_ShouldUpdate()
        {
            StreamingContent newContent = new StreamingContent(
                "Spaceballs",
                "Funny movie about star balls",
                Maturity.PG13,
                5,
                GenreType.SciFiComedy
                );
            bool wasUpdated = _repo.UpdateExistingContent("Spaceballs", newContent);

            Assert.IsTrue(wasUpdated);
            StreamingContent updatedContent = _repo.GetContentByTitle("Spaceballs");
            GenreType        expected       = GenreType.SciFiComedy;
            GenreType        actual         = updatedContent.GenreType;

            Assert.AreEqual(expected, actual);
            Console.WriteLine(updatedContent.Description);
        }
Exemple #9
0
        private void ShowContentByTitle()
        {
            _console.Clear();
            _console.WriteLine("Enter a title");
            string           title      = _console.ReadLine();
            StreamingContent foundTitle = _streamingRepo.GetContentByTitle(title);

            if (foundTitle != null)         // if title entered is found within the list   //if title is not found in the list it will return a null value
            {
                DisplayContent(foundTitle); //then display the foundTitle
            }

            else
            {
                _console.WriteLine("Invalid Title. Could not find any results.");
            }
            _console.WriteLine("Press any key to continue");
            _console.ReadKey();
        } // if method is grayed out it is not being referenced
Exemple #10
0
        private void CreateContent()
        {
            StreamingContent content = new StreamingContent();

            Console.WriteLine("\nCreating new content");
            Console.WriteLine("Please enter a title: ");
            content.Title = Console.ReadLine();
            Console.WriteLine("Enter content description: ");
            content.Description = Console.ReadLine();
            Console.WriteLine("Enter content run time in minutes: ");
            content.RunTimeInMinutes = double.Parse(Console.ReadLine()); //convert
            Console.WriteLine("Enter Content Star rating (1-10)");
            content.StarRating = double.Parse(Console.ReadLine());
            Console.WriteLine("Enter Maturity rating (G, PG, etc): ");
            content.MaturityRating = Console.ReadLine();
            Console.WriteLine("Is the content Family Friendly? (True/False)");
            content.IsFamilyFriendly = bool.Parse(Console.ReadLine());
            Console.WriteLine("Please choose a genre." +
                              "1. Action\n" +
                              "2. Bromance\n" +
                              "3. Documentary\n" +
                              "4. Drama\n" +
                              "5. Horror\n" +
                              "6. Noir\n" +
                              "7. RomCom\n" +
                              "8. SciFi\n" +
                              "9. WildWest");
            int genreNumber = int.Parse(Console.ReadLine());

            content.TypeOfGenre = (GenreType)genreNumber; //called casting


            _streamingRepo.AddContentToList(content);
            Console.WriteLine($"Added content to List:\n" +
                              $"\n{content.Title} - {content.Description}\n" +
                              $"{content.StarRating} Stars\n" +
                              $"Run time: {content.RunTimeInMinutes} minutes\n" +
                              $"Maturity rating: {content.MaturityRating}\n" +
                              $"Family Friendly: {content.IsFamilyFriendly}\n" +
                              $"Genre: {content.TypeOfGenre}");
            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
        public void SetTitle_ShouldGetCorrectString()
        {
            // Because we don't do everything in one class, these using statements are like adding contacts to your phone. Once you have the contact you can use their info to do whatever you are trying to do on that page
            // set up new streaming content
            // Arrange
            StreamingContent content = new StreamingContent();

            //set the title
            // Act
            content.Title = "Toy Story";

            //variables what you are expecting
            string expected = "Toy Story";
            string actual   = content.Title;

            //assert variables
            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void StreamingContent_SetTitle_ShouldBeCorrectString()
        {
            StreamingContent stream = new StreamingContent();

            stream.ContentID = "Shrek";
            stream.Length    = 100;
            stream.Rating    = 4.5f;
            stream.Genre     = "Children's Animated Comedy";
            stream.IsMature  = false;

            string actual   = stream.ContentID;
            string expected = "Shrek";

            Assert.AreEqual(actual, expected);
            Assert.AreEqual(stream.Length, 100);
            Assert.AreEqual(stream.Rating, 4, 5f);
            Assert.AreEqual(stream.Genre, "Comedy");
            Assert.AreEqual(stream.IsMature, false);
        }
        public void AddToList_ShouldGetNotNull()
        {
            // Arrange --> setting up the playing field
            StreamingContent content = new StreamingContent(); // sets up a new instance of conent

            content.Title = "Toy Story";


            StreamingContentRepository repository = new StreamingContentRepository();


            // Act --> Get / Run the code we want to test
            repository.AddContentToList(content);
            StreamingContent contentFromDirectory = repository.GetContentByTitle("Toy Story");


            //Assert --> Use the assert class to verify the expected outcome
            Assert.IsNotNull(contentFromDirectory);
        }
Exemple #14
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. Try again.");
            }
            Console.ReadKey();
        }
        private void DeleteContent()
        {
            StreamingContent editedContent = new StreamingContent();

            Console.Clear();
            Console.WriteLine("Enter Title to delete:");
            string deleteContentTitle = Console.ReadLine();

            bool didDelete = _contentRepo.RemoveContentFromList(deleteContentTitle);

            if (didDelete)
            {
                Console.WriteLine("Update Successful");
            }
            else
            {
                Console.WriteLine("Opps");
            }
        }
Exemple #16
0
        // Add New Content
        private void CreateNewContent()
        {
            // need to build a StreamingContent object first
            // we can either new up a blank StreamingContent object and access properties directly (the way Josh would've done it)
            // StreamingContent newContent = new StreamingContent();
            // newContent.Title = "";
            // or gather all data then use overloaded constructor like below

            // Gather values for all properties for the StreamingContent object
            // Title
            _console.Write("Enter a Title: ");
            // _console.Write with a ReadLine will let user input on the same line as WriteLine (Title: "user input")
            string title = _console.ReadLine();

            // Description
            _console.Write("Enter a Description: ");
            string description = _console.ReadLine();

            // MaturityRating
            // calling helper method made below
            MaturityRating maturityRating = GetMaturityRating();

            // StarRating
            _console.Write("Enter the Star Rating (1-5): ");
            double starRating = double.Parse(_console.ReadLine());

            // parse method is a little fragile that if user typed something that wasn't a double it will not parse correctly
            // maybe refactor later so it won't break when not given a number

            // Release Year
            _console.Write("Enter the Release Year: ");
            int releaseYear = int.Parse(_console.ReadLine());

            // Genre
            GenreType genre = GetGenreType();

            // Construct a StreamingContent object given the above values
            StreamingContent newContent = new StreamingContent(title, description, maturityRating, starRating, releaseYear, genre);

            // Add the StreamingContent object to the repository ("Save" the content)
            _streamingRepo.AddContentToDirectory(newContent);
        }
Exemple #17
0
        private void ShowContentByTitle()
        {
            _console.Clear();
            _console.WriteLine("Enter a title");
            string title = _console.ReadLine();

            StreamingContent content = _repo.GetContentByTitle(title);

            if (content == null)
            {
                _console.WriteLine("No content found");
            }
            else
            {
                DisplayContent(content);
            }

            _console.WriteLine("Press any key to continue...");
            _console.ReadKey();
        }
        public void AddToList_AddStreamingContentObject_ListCountShouldBeCorrectInt()
        {
            //Arrange
            StreamingContentRepository streamingRepo = new StreamingContentRepository();
            List <StreamingContent>    contents      = streamingRepo.GetStreamingContentList();

            StreamingContent contentThree = new StreamingContent("Jaws", 10, 2.12f, "A big shark.", true, "R", GenreType.Action);
            StreamingContent contentFour  = new StreamingContent("Star Wars", 10, 1.46f, "A long time ago...", true, "PG-13", GenreType.SciFi);

            //Act
            int expected = 2;

            streamingRepo.AddToList(contentThree);
            streamingRepo.AddToList(contentFour);

            int actual = contents.Count;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        private void ViewContentByTitle()
        {
            Console.WriteLine("Enter Title to display:");
            string           contentTitle = Console.ReadLine();
            StreamingContent content      = _contentRepo.GetContentByTitle(contentTitle);

            if (content == null)
            {
                Console.WriteLine("No content found!");
            }
            else
            {
                Console.WriteLine($"Title: {content.Title},\n" +
                                  $" Description: {content.Description}\n" +
                                  $" Maturity Rating: {content.MaturityRating}\n" +
                                  $" Star Rating: {content.StarRating}\n" +
                                  $" Family Friendly?: {content.IsFamilyFriendly}\n" +
                                  $" Genre:  {content.TypeOfGenre}");
            }
        }
Exemple #20
0
        private void SeedContent()
        {
            StreamingContent futureWar = new StreamingContent(
                "Future War",
                "a war in the future",
                10.0,
                Genre.SciFi,
                MaturityRating.G
                );
            StreamingContent theRoom = new StreamingContent(
                "The Room",
                "Everyone betrays Johnny and he's fed up with this world",
                10.0,
                Genre.Documentary,
                MaturityRating.G
                );

            _repo.AddContentToDirectory(futureWar);
            _repo.AddContentToDirectory(theRoom);
        }
Exemple #21
0
        private void RemoveContent()
        {
            Console.Clear();
            List <StreamingContent> contentList = _streamingRepo.GetContent();
            int count = 0;

            foreach (StreamingContent content in contentList)
            {
                count++;
                Console.WriteLine($"{count} - {content.Title}");
            }
            Console.WriteLine();
            Console.Write("Which item would you like to remove? (Or enter 0 to go back)...");
            int targetContentId = int.Parse(Console.ReadLine());
            int targetIndex     = targetContentId - 1;

            Console.WriteLine();
            if (targetIndex >= 0 && targetIndex < contentList.Count)
            {
                StreamingContent desiredContent = contentList[targetIndex];
                if (_streamingRepo.DeleteExistingContent(desiredContent))
                {
                    Console.WriteLine($"{desiredContent.Title} has been removed");
                }
                else
                {
                    Console.WriteLine("I'm sorry, Dave. I'm afraid I can't do that.");
                }
            }
            if (targetIndex == -1)
            {
                Console.WriteLine("You have not removed any content!");
            }
            else
            {
                Console.WriteLine("No content had that ID.");
            }
            Console.WriteLine();
            Console.Write("Press any key to continue....");
            Console.ReadKey();
        }
Exemple #22
0
        private void AddNewMovie() //Tile, SarRating, RunTime, Summary, IsFamilyFriendly
        {
            Console.WriteLine("Title of movie: ");
            string title = Console.ReadLine();

            Console.WriteLine("Runtime: ");
            string runTime       = Console.ReadLine();
            float  runTimeParsed = float.Parse(runTime);

            Console.WriteLine("What would you rate this movie?");
            string userRating = Console.ReadLine();
            int    starRating = int.Parse(userRating);

            Console.WriteLine("Please describe the movie: ");
            string summary = Console.ReadLine();

            Console.WriteLine("Is the movie family friendly? true or false");
            string familyFriendlyAsString = Console.ReadLine();
            bool   isFamilyFriendly       = bool.Parse(familyFriendlyAsString);

            Console.WriteLine("What is the official movie rating? e.g. G, PG, PG-13, R");
            string movieRating = Console.ReadLine();

            Console.WriteLine("What is genre?\n" +
                              "1. Drama\n" +
                              "2. Action\n" +
                              "3. Horror\n" +
                              "4. Comedy\n" +
                              "5. Documentary\n" +
                              "6. RomCom\n" +
                              "7. Indie\n" +
                              "8. Science Fiction");
            string genreAsString = Console.ReadLine();
            int    genreAsInt    = int.Parse(genreAsString);

            GenreType genre = (GenreType)genreAsInt;

            StreamingContent movie = new StreamingContent(title, starRating, runTimeParsed, summary, isFamilyFriendly, movieRating, genre);

            _streamingRepo.AddToList(movie);
        }
        public void UpdateContent_ShouldUpdate()
        {
            StreamingContent newContent = new StreamingContent(
                "Spaceballs",
                "A star pilot and his sidekick must come to the rescue of a princess",
                Maturity.PG13,
                5,
                GenreType.SciFiComedy
                );

            bool wasUpdated = _repo.UpdateExistingContent("Spaceballs", newContent);

            Assert.IsTrue(wasUpdated);
            StreamingContent updatedContent = _repo.GetContentByTitle("Spaceballs");

            GenreType expected = GenreType.SciFiComedy;
            GenreType actual   = updatedContent.GenreType;

            Assert.AreEqual(expected, actual);
            Console.WriteLine(updatedContent.Description);
        }
        public void GetDirectory_ShouldReturnCorrectCollection()
        {
            // Arrange, Act, Assert - Triple A Paradigm

            // Arrange --> Setting up the playing field
            // Everything we have to do before we start running code we're testing
            StreamingContentRepository repo = new StreamingContentRepository();
            // creating something
            StreamingContent orange = new StreamingContent();

            // then passing it through to the method
            repo.AddContentToDirectory(orange);

            // Act --> Get or run the code we want to test
            List <StreamingContent> directory = repo.GetDirectory();

            bool directoryHasOrange = directory.Contains(orange);

            // Assert --> Using the Assert class to verify the expected outcome
            Assert.IsTrue(directoryHasOrange);
        }
Exemple #25
0
 private void DisplayContent(StreamingContent content)
 {
     if (content.GetType().Name == "Movie")
     {
         _console.WriteLine("======== Movie ========");
         Movie movie = (Movie)content;
         _console.WriteLine($"Run Time: {movie.RunTime}");
     }
     if (content.GetType().Name == "Show")
     {
         _console.WriteLine("======== Show ========");
         Show show = (Show)content;
         _console.WriteLine($"Episodes: {show.EpisodeCount}");
     }
     _console.WriteLine($"Title: {content.Title}");
     _console.WriteLine($"Description: {content.Description}");
     _console.WriteLine($"Star Rating: {content.StarRating}");
     _console.WriteLine($"Maturity Rating: {content.MaturityRating}");
     _console.WriteLine($"Genre: {content.Genre}");
     _console.WriteLine($"Is it family friendly? {content.IsFamilyFriendly}");
 }
        private void AddNewMovie()
        {
            Console.WriteLine("What is the title of the movie?");
            string title = Console.ReadLine();

            Console.WriteLine("How would you rate the movie?");
            string starRating       = Console.ReadLine();
            int    starRatingParsed = int.Parse(starRating);

            Console.WriteLine("Runtime: ");
            string runTime       = Console.ReadLine();
            float  runTimeParsed = float.Parse(runTime);

            Console.WriteLine("Add a synopsis:");
            string summary = Console.ReadLine();

            Console.WriteLine("Is the movie family friendly? True of False.");
            string familyFriendlyString = Console.ReadLine();
            bool   isFamilyFriendly     = bool.Parse(familyFriendlyString);

            Console.WriteLine("What is the MPAA Rating? G, PG, PG-13, or R?");
            string movieRating = Console.ReadLine();

            Console.WriteLine("What is the genre of the movie?\n" +
                              "1. Drama\n" +
                              "2. Action\n" +
                              "3. Horror\n" +
                              "4. Comedy\n" +
                              "5. Documentary\n" +
                              "6. RomCom\n" +
                              "7. Indie\n" +
                              "8. SciFi");
            string    genreAsString = Console.ReadLine();
            int       genreInt      = int.Parse(genreAsString);
            GenreType genre         = (GenreType)genreInt;

            StreamingContent movie = new StreamingContent(title, starRatingParsed, runTimeParsed, summary, isFamilyFriendly, movieRating, genre);

            _streamingRepo.AddToList(movie);
        }
Exemple #27
0
        //creating Delete part as Remove content
        private void RemoveContent()
        {
            //Prompting user below
            Console.WriteLine("Which item would you like to remove?..");
            //gathering the content collection or the option that user have by using list 
            List<StreamingContent> contentList = _streamingRepo.GetContent();
            //below is so it start at 0
            int count = 0;
            //foreach case below
            foreach (StreamingContent content in contentList)
            {//count++ adds 1 to the int
                count++;
                Console.WriteLine($"{count}. {content.Title}");
            }
            // giving it target ID and turning into int
            int targetContentID = int.Parse(Console.ReadLine());
            //below turning into index and create if statement and subtract 1

            int targetIndex = targetContentID - 1;
            if (targetIndex >= 0 && targetIndex < contentList.Count)
            {//grabing and saving the object below
                //with index we do [] brakets
                StreamingContent desiredContent = contentList[targetIndex];
                //if within a if
                if (_streamingRepo.DeleteExistingContent(desiredContent))
                {
                    Console.WriteLine($"{desiredContent.Title} has been removed");
                }
                // if it doesn't get deleted then add else for answer
                else { Console.WriteLine("I'm sorry, Dave. I'm afraid I can't do that."); }
            }
            //this is linked to the first if statement as its response
            else
            {
                Console.WriteLine("No content had that ID");
            }
            Console.WriteLine("Press any key to continue.......");
            // read key only read or gives option of 1 caracter where readline keeps reading rest of the code
            Console.ReadKey();
        }
Exemple #28
0
        private void RemoveContentFromList()
        {
            // Prompt user Which Item to Remove from List.
            Console.WriteLine("Which Item Would You Like to Remove?");

            // Need a List of Items.
            List <StreamingContent> contentList = _streamingRepository.GetContents();
            int count = 0;

            foreach (var content in contentList)
            {
                count++;
                Console.WriteLine($"{count}) {content.Title}");
            }

            // Take in user Response.
            int targetContentID = int.Parse(Console.ReadLine());
            int correctIndex    = targetContentID - 1;

            if (correctIndex >= 0 && correctIndex < contentList.Count)
            {
                StreamingContent desiredContent = contentList[correctIndex];
                if (_streamingRepository.DeleteExistingContent(desiredContent))
                {
                    Console.WriteLine($"{desiredContent.Title} Has Been Removed!");
                }
                else
                {
                    Console.WriteLine("I'm sorry, Dave. I'm afraid I can't do that ...");
                }
            }
            else
            {
                Console.WriteLine("Invalad Opiton!");
            }
            Console.WriteLine("Press Any Key to Continue ...");
            Console.ReadKey();

            // Goal: Remove Item.
        }
        private void FindByTitle()
        {
findByTitle:
            StreamingContent content = new StreamingContent();

            Console.Clear();
            Console.WriteLine("Enter the title of the content you would like to find");
            string title = Console.ReadLine();

            content = _streamingRepo.GetContentByTitle(title);
            Console.Clear();

            if (content == null)
            {
                string tryAgain;
                Console.WriteLine($"Could not find {title}.\nDo you want to try another search? \n1)Yes \n2)No");
                tryAgain = Console.ReadLine().ToLower();
                switch (tryAgain)
                {
                case "1":
                    goto findByTitle;

                case "yes":
                    goto findByTitle;

                case "2":
                    break;

                case "no":
                    break;
                }
            }
            else
            {
                DisplaySimple(content);
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
                Console.Clear();
            }
        }
        /*private void FindByTitle()
         * {
         *  List<StreamingContent> listOfContents = _streamingRepo.GetContent();
         *  _console.WriteLine("Enter the title of the content you are searching for: ");
         *  string title = _console.ReadLine();
         *  StreamingContent found;
         *  bool isWithin = false;
         *  foreach(StreamingContent content in listOfContents)
         *  {
         *      if(content.Title.ToLower() == title.ToLower())
         *      {
         *          found = content;
         *          isWithin = true;
         *      }
         *  }
         *  if (isWithin)
         *  {
         *      DisplayAllProps(found);
         *  }
         *  else
         *  {
         *      _console.WriteLine($"{title} was not found in the repository.");
         *  }
         * }*/
        private void ShowContentByTitle()//Same as above
        {
            _console.Clear();
            //Show only one object found by title
            //Step one: get title from user
            _console.WriteLine("Enter the title: ");
            string title = _console.ReadLine();
            //Use title to find the ONE object
            StreamingContent foundContent = _streamingRepo.GetContentByTitle(title);

            //If object found, display data / if not, inform user that title does not exist
            if (foundContent != null)
            {
                DisplayAllProps(foundContent);
            }
            else
            {
                _console.WriteLine("There are no titles that matched the one you gave me.");
            }
            _console.WriteLine("Press any key to continue.....");
            _console.ReadKey();
        }