//Method that prompts user for which StreamingContent object they want to delete (use the title to find it) //remove it from the _contentDirectory. //Bonus: Display all the options for them to select from //work until 2:15 private void DisplayContent(GreenContent content) { Console.WriteLine($"Car Name: {content.CarName}"); Console.WriteLine($"Mileage to Refill: {content.MileageToRefill}"); Console.WriteLine($"Year Made: {content.YearMade}"); Console.WriteLine($"Car Price: {content.CarPrice}"); Console.WriteLine($"Car Type: {content.CarType}"); }
private void DeleteContentByTitle() { ShowAllContent(); Console.ReadKey(); Console.WriteLine("Enter the car's name for the car you would like to delete."); string titleToDelete = Console.ReadLine(); GreenContent contentToDelete = _repo.GetContentByTitle(titleToDelete); GreenContent contentToDeleteGas = _gasRepo.GetContentByTitle(titleToDelete); GreenContent contentToDeleteElectric = _electricRepo.GetContentByTitle(titleToDelete); GreenContent contentToDeleteHybrid = _hybridRepo.GetContentByTitle(titleToDelete); bool wasDeleted = _repo.DeleteExistingContent(contentToDelete); bool wasDeletedGas = _gasRepo.DeleteExistingContent(contentToDelete); bool wasDeletedElectric = _electricRepo.DeleteExistingContent(contentToDelete); bool wasDeletedHybrid = _hybridRepo.DeleteExistingContent(contentToDelete); if (wasDeleted) { Console.WriteLine("This content was successfully deleted."); } else { Console.WriteLine("Content could not be deleted"); } if (wasDeletedGas) { Console.WriteLine("This content was successfully deleted."); } else { Console.WriteLine("Content could not be deleted"); } if (wasDeletedElectric) { Console.WriteLine("This content was successfully deleted."); } else { Console.WriteLine("Content could not be deleted"); } if (wasDeletedHybrid) { Console.WriteLine("This content was successfully deleted."); } else { Console.WriteLine("Content could not be deleted"); } }
public void AddToDirectory_ShouldGetCorrectBoolean() { //Arrange GreenContent content = new GreenContent(); GreenRepo repository = new GreenRepo(); //Act bool addResult = repository.AddContentToDirectory(content); //Assert Assert.IsTrue(addResult); }
public void GetByTitle_ShouldReturnCorrectContent() { //Arrange GreenRepo repo = new GreenRepo(); GreenContent newContent = new GreenContent(); repo.AddContentToDirectory(newContent); string title = ""; //Act GreenContent searchResult = repo.GetContentByTitle(title); //Assert Assert.AreEqual(searchResult.CarName, title); }
public void DeleteExistingContent_ShouldReturnTrue() { //Arrange GreenRepo repo = new GreenRepo(); GreenContent content = new GreenContent(); repo.AddContentToDirectory(content); //Act GreenContent oldContent = repo.GetContentByTitle(); bool removeResult = repo.DeleteExistingContent(oldContent); //Assert Assert.IsNull(removeResult); }
public void UpdateExistingContent_ShouldReturnTrue() { //Arrange GreenRepo repo = new GreenRepo(); GreenContent oldContent = new GreenContent(); repo.AddContentToDirectory(oldContent); GreenContent newContent = new GreenContent(); //Act bool updateResult = repo.UpdateExistingContent(oldContent.CarName, newContent); //Assert Assert.IsTrue(updateResult); }
public void GetDirectory_ShouldReturnCorrectCollection() { //Arrange GreenContent content = new GreenContent(); GreenRepo repo = new GreenRepo(); repo.AddContentToDirectory(content); //Act List <GreenContent> contents = repo.GetContents(); bool directoryHasContent = contents.Contains(content); //Assert Assert.IsTrue(directoryHasContent); }
private void ShowContentByTitle() { Console.Clear(); Console.WriteLine("Enter the title of the content you'd like to see."); string title = Console.ReadLine(); GreenContent content = _repo.GetContentByTitle(title); if (content != null) { DisplayContent(content); } else { Console.WriteLine("That title doesn't exist."); } Console.ReadKey(); }
private void CreateNewContent() { Console.Clear(); GreenContent newContent = new GreenContent(); Console.WriteLine("Please enter the name of the new car."); newContent.CarName = Console.ReadLine(); Console.WriteLine("Please enter a price for this car."); string carPriceAsString = Console.ReadLine(); int carPriceAsInt = int.Parse(carPriceAsString); newContent.CarPrice = carPriceAsInt; Console.WriteLine("Please enter a mileage to a refill of either type gas or electric."); string mileageToRefillAsString = Console.ReadLine(); int mileageToRefillAsInt = int.Parse(mileageToRefillAsString); newContent.MileageToRefill = mileageToRefillAsInt; Console.WriteLine("Please enter a year made for this car."); string yearMadeAsString = Console.ReadLine(); int yearMadeAsInt = int.Parse(yearMadeAsString); newContent.YearMade = yearMadeAsInt; Console.WriteLine("Select car type."); Console.WriteLine("1. Gas"); Console.WriteLine("2. Electric"); Console.WriteLine("3. Hybrid"); string carTypeInput = Console.ReadLine(); if (carTypeInput == "1") { newContent.CarType = CarType.Gas; bool wasAdded = _gasRepo.AddContentToDirectory(newContent); if (wasAdded == true) { Console.WriteLine("Your content was succesfully added."); } else { Console.WriteLine("Oops something went wrong. Your content was not added."); } } else if (carTypeInput == "2") { newContent.CarType = CarType.Electric; bool wasAdded = _electricRepo.AddContentToDirectory(newContent); if (wasAdded == true) { Console.WriteLine("Your content was succesfully added."); } else { Console.WriteLine("Oops something went wrong. Your content was not added."); } } else if (carTypeInput == "3") { newContent.CarType = CarType.Hybrid; bool wasAdded = _hybridRepo.AddContentToDirectory(newContent); if (wasAdded == true) { Console.WriteLine("Your content was succesfully added."); } else { Console.WriteLine("Oops something went wrong. Your content was not added."); } } bool wasAddedRepo = _repo.AddContentToDirectory(newContent); if (wasAddedRepo == true) { Console.WriteLine("Your content was succesfully added."); } else { Console.WriteLine("Oops something went wrong. Your content was not added."); } }