public void EditDriverTest()
        {
            Driver newDriver = new Driver(00001, "John Smith-Jones", new DriverData(3, 3, 1, 1));

            _insuranceRepo.EditDriver(00001, newDriver);

            Driver actual = _insuranceRepo.GetOneDriver(00001);

            Assert.AreEqual(newDriver.DriverName, actual.DriverName);
            Assert.AreEqual(newDriver.DriverData.SpeedingFrequency, actual.DriverData.SpeedingFrequency);
        }
Example #2
0
        public void UpdateDriver()
        {
            Console.Write("Enter the current ID of the driver to update: ");
            int oldID = int.Parse(Console.ReadLine());

            Console.WriteLine("Would you like to update: \n" +
                              "1. The full driver entry\n" +
                              "2. Just the data for a specific driver");
            string userInput = Console.ReadLine();

            switch (userInput)
            {
            case "1":
                Console.Write("Enter the new Driver ID: ");
                int newID = int.Parse(Console.ReadLine());
                Console.Write("Enter the new Driver Name: ");
                string newName = Console.ReadLine();
                Console.Write("Enter the percentage of time speeding as a whole number: ");
                int timeSpeeding = int.Parse(Console.ReadLine());
                Console.Write("Enter the percentage of time spent out of lane: ");
                int timeOutOfLane = int.Parse(Console.ReadLine());
                Console.Write("Enter the percentage of time following too closely: ");
                int timeClose = int.Parse(Console.ReadLine());
                Console.Write("Enter the number of times rolling through stop signs: ");
                int    rollingStop = int.Parse(Console.ReadLine());
                Driver newDriver   = new Driver(newID, newName, new DriverData(timeSpeeding, timeOutOfLane, timeClose, rollingStop));
                _insuranceRepo.EditDriver(oldID, newDriver);
                break;

            case "2":
                Console.Write("Enter the percentage of time speeding as a whole number: ");
                int newSpeeding = int.Parse(Console.ReadLine());
                Console.Write("Enter the percentage of time spent out of lane: ");
                int newOutOfLane = int.Parse(Console.ReadLine());
                Console.Write("Enter the percentage of time following too closely: ");
                int newClose = int.Parse(Console.ReadLine());
                Console.Write("Enter the number of times rolling through stop signs: ");
                int        newRollingStop = int.Parse(Console.ReadLine());
                DriverData newData        = new DriverData(newSpeeding, newOutOfLane, newClose, newRollingStop);
                break;

            default:
                Console.WriteLine("Please enter 1 or 2");
                break;
            }
            Console.WriteLine("Driver updated\n" +
                              "Press any key to continue...");
            Console.ReadKey();
        }