public void Cars_AddToList_ShouldAddToList() { //arrange Cars content = new Cars(CarType.Electric, 123000, 15.5, "Tesla", "X", 120, "123ABC"); //act newRepo.AddToList(content); List <Cars> list = newRepo.GetList(); var actual = list.Count; var expected = 1; //assert Assert.AreEqual(actual, expected); }
public void Cars_RemoveCarFromList_ShouldRemoveACarFromAList() { //arrange Cars_Repository carRepo = new Cars_Repository(); Cars content = new Cars(CarType.Electric, 123000, 0, "Tesla", "X", 120, "123ABC"); Cars content2 = new Cars(CarType.Gas, 123000, 15.5, "Mazda", "3", 150, "321CBA"); //act carRepo.AddToList(content); carRepo.AddToList(content2); carRepo.RemovCarFromList("123ABC"); List <Cars> list = carRepo.GetList(); var actual = list.Count; var expected = 1; //assert Assert.AreEqual(actual, expected); }
public void AddToList() { Console.Clear(); Console.WriteLine("What Category Would You Like This Car To Be In? Enter The Number\n" + "1. Gas\n" + "2. Electric\n" + "3. Hybrid"); string carTypeAsString = Console.ReadLine(); int carType = 0; bool correct = IntTest(carTypeAsString); if (correct && carType <= 4) { Console.Clear(); carType = int.Parse(carTypeAsString); CarType type = (CarType)int.Parse(carTypeAsString); Console.Clear(); Console.WriteLine($"You successfully set the type of car to {type}! Press enter to continue."); Console.ReadLine(); Console.Clear(); Console.WriteLine("What Is The Mileage On This Car?"); string mileageAsString = Console.ReadLine(); double mileageCar = 0; bool correct2 = DoubleTest(mileageAsString); if (correct2) { mileageCar = double.Parse(mileageAsString); Console.Clear(); Console.WriteLine($"You have successfully set the mileage of the car to {mileageCar}! Press enter to continue."); Console.ReadLine(); Console.Clear(); Console.WriteLine("What Is This Cars Miles Per Gallon?"); string mpgAsString = Console.ReadLine(); double mpg = 0; bool correct3 = DoubleTest(mpgAsString); if (correct3) { mpg = double.Parse(mpgAsString); Console.Clear(); Console.WriteLine($"You have successfully set the miles per gallon to {mpg}! Press enter to continue."); Console.ReadLine(); Console.Clear(); Console.WriteLine("What is the Make Of The Car (Company)?"); string carMake = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You have successfully set the car make to {carMake}! Press enter to continue."); Console.ReadLine(); Console.Clear(); Console.WriteLine("What Is The Model Of The Car?"); string carModel = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You have successfully set the car model to {carModel}! Press enter to continue"); Console.ReadLine(); Console.Clear(); Console.WriteLine("What Is This Cars Wrecks Per Month?"); string carWrecksAsString = Console.ReadLine(); double carWrecks = 0; bool correct4 = DoubleTest(carWrecksAsString); if (correct4) { carWrecks = double.Parse(carWrecksAsString); Console.Clear(); Console.WriteLine($"You have successfully set the car wrecks to {carWrecks}! Press enter to continue."); Console.ReadLine(); Console.Clear(); Console.WriteLine("What is the Car VIN?"); string carVin = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You have successfully set the car's VIN to {carVin}"); Console.ReadLine(); Cars newContent = new Cars(type, mileageCar, mpg, carMake, carModel, carWrecks, carVin); _newCarRepo.AddToList(newContent); } else { Console.Clear(); Console.WriteLine("Please Enter A Valid Car Wreck Count. You will be redirected, press enter"); Console.ReadLine(); AddToList(); } } else { Console.Clear(); Console.WriteLine("Please Enter A Valid MPG. You will be redirected, press enter."); Console.ReadLine(); AddToList(); } } else { Console.Clear(); Console.WriteLine("Please Enter A Mileage Number. You will be redirected, press enter."); Console.ReadLine(); AddToList(); } } else { Console.Clear(); Console.WriteLine("Please Enter A Valid Car Type. You will be redirected, press enter."); Console.ReadLine(); AddToList(); } }