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(); }
public void AddToDirectory_ShouldGetCorrectBoolean() { StreamingContentBase content = new StreamingContentBase(); StreamingContentRepo repository = new StreamingContentRepo(); bool addResult = repository.AddContentToDirectory(content); Assert.IsTrue(addResult); }
public void CheckIfFamilyFriendlyBasedOnMaturityRating() { StreamingContentBase isFamilyFriendly = new StreamingContentBase(); isFamilyFriendly.MaturityRating = MaturityRating.R; bool check = isFamilyFriendly.IsFamilyFriendly; Assert.IsFalse(check); }
public void SetTitle_ShouldReturnCorrectString() { //Arrange StreamingContentBase var1 = new StreamingContentBase(); //Act var1.Title = "Movie 2"; //Assert Assert.AreEqual(var1.Title, "Movie 2"); }
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); }
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); }
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); }
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); }
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); }
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(); }
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); }
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"); } }
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(); }