public void CreateCar()
        {
            Console.WriteLine("Enter car name: ");
            string carName = Console.ReadLine();

            Console.WriteLine("Enter car type: \n" +
                              "1. Electric\n" +
                              "2. Hybrid\n" +
                              "3. Gas\n");
            string  typeAsString = Console.ReadLine();
            int     typeInt      = int.Parse(typeAsString);
            CarType type         = (CarType)typeInt;

            Console.WriteLine("Enter car engine: ");
            string carEngine = Console.ReadLine();

            Console.WriteLine("Enter gas mileage: ");
            string gasMileage = Console.ReadLine();

            Console.WriteLine("Enter driving type: ");
            string drivingType = Console.ReadLine();

            CarContent content = new CarContent(carName, type, carEngine, gasMileage, drivingType);

            _carRepo.AddToList(content);
        }
Пример #2
0
        public void AddToListTest()
        {
            CarRepository     carRepo = new CarRepository();
            List <CarContent> content = carRepo.GetCarList();

            CarContent contentTwo = new CarContent("Buick", CarType.Gas, "V6", "30mpg", "Front Wheel");

            int expected = 1;

            carRepo.AddToList(contentTwo);

            Assert.AreEqual(expected, content.Count);
        }
        public void UpdateMenu(string userChoice)
        {
            CarContent content = _carRepo.GetCarByName(userChoice);

            Console.WriteLine("Here are your options: \n" +
                              "1. Change car name.\n" +
                              "2. Change car type.\n" +
                              "3. Change car engine.\n" +
                              "4. Change car mileage.\n" +
                              "5. Change driving type.\n");
            string userResponse = Console.ReadLine();
            int    response     = int.Parse(userResponse);

            switch (response)
            {
            case 1:
                Console.WriteLine("Enter new car name: ");
                string carName = Console.ReadLine();
                content.CarName = carName;
                break;

            case 2:
                Console.WriteLine("Enter new car type: \n" +
                                  "1. Electric\n" +
                                  "2. Hybrid\n" +
                                  "3. Gas\n");
                string  typeString = Console.ReadLine();
                int     typeInt    = int.Parse(typeString);
                CarType type       = (CarType)typeInt;
                content.Type = type;
                break;

            case 3:
                Console.WriteLine("Enter new car engine: ");
                string carEngine = Console.ReadLine();
                content.CarEngine = carEngine;
                break;

            case 4:
                Console.WriteLine("Enter new gas mileage: ");
                string gasMileage = Console.ReadLine();
                content.GasMileage = gasMileage;
                break;

            case 5:
                Console.WriteLine("Enter new driving type: ");
                string drivingType = Console.ReadLine();
                content.DrivingType = drivingType;
                break;
            }
        }
Пример #4
0
        public void ObjTest()
        {
            CarContent contentOne = new CarContent();

            contentOne.CarName = "Buick";

            string expected = "Buick";

            Assert.AreEqual(expected, contentOne.CarName);

            CarContent contentTwo = new CarContent("Buick", CarType.Gas, "V6", "30mpg", "Front Wheel");

            string  expectedName        = "Buick";
            CarType expectedType        = CarType.Gas;
            string  expectedEngine      = "V6";
            string  expectedMileage     = "30mpg";
            string  expectedDrivingType = "Front Wheel";

            Assert.AreEqual(expectedName, contentTwo.CarName);
            Assert.AreEqual(expectedType, contentTwo.Type);
            Assert.AreEqual(expectedEngine, contentTwo.CarEngine);
            Assert.AreEqual(expectedMileage, contentTwo.GasMileage);
            Assert.AreEqual(expectedDrivingType, contentTwo.DrivingType);
        }