예제 #1
0
        public void AddAndGetListOfCars()
        {
            GreenRepository repoInfo      = new GreenRepository();
            GreenPlan       customerInfo  = new GreenPlan(1, 2015, "Honda", "Sonata", 32d, CarType.Hybrid);
            GreenPlan       customerInfo2 = new GreenPlan(2, 2010, "Honda", "Sonata", 32d, CarType.Hybrid);

            repoInfo.AddCarToList(customerInfo);
            repoInfo.AddCarToList(customerInfo2);
            List <GreenPlan> list = repoInfo.GetAllCarInfo();

            var expected = 2;
            var actual   = list.Count;

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        private void EditACar()
        {
            Console.WriteLine("What is the cars ID?");
            int carID = int.Parse(Console.ReadLine());

            Console.WriteLine("What number value would you like to change?\n" +
                              "1: Model Name\n" +
                              "2: Make Name\n" +
                              "3: Year\n" +
                              "4: Gas Mileage\n" +
                              "5: Car Type");
            string carChange = (Console.ReadLine());

            switch (carChange)
            {
            case "1":
                Console.WriteLine("What is the new model name?");
                string modelName = Console.ReadLine();
                foreach (GreenPlan crud in _carRepo.GetAllCarInfo())
                {
                    if (crud.CarID == carID)
                    {
                        crud.ModelOfCar = modelName;
                    }
                }

                break;

            case "2":
                Console.WriteLine("What is the new make name?");
                string makeName = Console.ReadLine();
                foreach (GreenPlan crud in _carRepo.GetAllCarInfo())
                {
                    if (crud.CarID == carID)
                    {
                        crud.MakeOfCar = makeName;
                    }
                }

                break;

            case "3":
                Console.WriteLine("What is the new year of the car?");
                int carYear = int.Parse(Console.ReadLine());
                foreach (GreenPlan crud in _carRepo.GetAllCarInfo())
                {
                    if (crud.CarID == carID)
                    {
                        crud.YearOfCar = carYear;
                    }
                }

                break;

            case "4":
                Console.WriteLine("What is the new gas mileage of the car?");
                double gasMileage = double.Parse(Console.ReadLine());
                foreach (GreenPlan crud in _carRepo.GetAllCarInfo())
                {
                    if (crud.CarID == carID)
                    {
                        crud.GasMileage = gasMileage;
                    }
                }

                break;

            case "5":
                Console.WriteLine("What is the new customer type?\n" +
                                  "1: Electric\n" +
                                  "2: Hybrid\n" +
                                  "3: Gas");
                int     cType   = int.Parse(Console.ReadLine());
                CarType carType = (CarType)cType;
                foreach (GreenPlan crud in _carRepo.GetAllCarInfo())
                {
                    if (crud.CarID == carID)
                    {
                        crud.CarType = carType;
                    }
                }

                break;
            }
        }