Example #1
0
        public void ViewCar()
        {
            Console.Clear();
            KomodoLogo();
            Console.WriteLine("<<<<<<<< View Car >>>>>>>");
            Console.WriteLine("Enter Make:");
            string make = Console.ReadLine();

            Console.WriteLine("Enter Model:");
            string model = Console.ReadLine();

            Console.WriteLine("Enter Year:");
            string year  = Console.ReadLine();
            string carID = year.ToString() + make.ToLower() + model.ToLower();
            Car    car   = _repo.GetCarByID(carID);

            if (car != null)
            {
                DisplayCar(car);
            }
            else
            {
                Console.WriteLine("Car not found. \nPress any key to return to main menu.");
            }

            Console.ReadKey();
        }
        public void DeleteCar()//Delete a car from repo
        {
            //Arrange
            GasCar   car  = new GasCar("ford", "mustang", 2020);
            Car_Repo repo = new Car_Repo();

            repo.AddCar(car);
            string id = "2020fordmustang";


            //Act
            Car  oldCar       = repo.GetCarByID(id);
            bool removeResult = repo.DeleteCar(oldCar);

            //Assert
            Assert.IsTrue(removeResult);
        }
        public void GetCarByID_ShouldReturnCorrectCar()//Read
        {
            //Arrange
            GasCar    car  = new GasCar("ford", "mustang", 2020);
            HybridCar car2 = new HybridCar("toyota", "prius", 2019);
            Car_Repo  repo = new Car_Repo();

            repo.AddCar(car);
            repo.AddCar(car2);

            string id = "2020fordmustang";

            //Act
            var localCar = repo.GetCarByID(id);

            //assert
            Assert.AreEqual(localCar.CarID, id);
        }