public void slotNumberForRegNo_NegTest() { Car[] cars = new Car[3] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; int slotNo = commands.slot_number_for_registration_number("KA-01-HH-0000"); Assert.IsTrue(slotNo == -1); }
public void StatusCheckTest() { Car[] cars = new Car[2] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; commands.status(); Program.ParkingLot = null; Assert.ThrowsException <BaseException>(() => commands.status()); }
public void ParkCarTest() { Car[] cars = new Car[5] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, null, new Car { Color = "brown", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 5 } }; sampleLot = new Model.ParkingLot(5) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; Assert.IsTrue(Program.ParkingLot.Cars[3] == null); commands.park("KA-01-ET-8787", "white"); Assert.IsTrue(Program.ParkingLot.Cars[3] != null && Program.ParkingLot.Cars[3].Color.Equals("white")); }
public void slotNumbersForCarswithColor_NegTest() { Car[] cars = new Car[5] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, null, new Car { Color = "blue", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 5 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; List <int> slotNos = commands.slot_numbers_for_cars_with_colour("purple"); Assert.IsTrue(slotNos == null); }
public void RegNosWithColorTest() { Car[] cars = new Car[5] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, null, new Car { Color = "red", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 5 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; List <string> regsNos = commands.registration_numbers_for_cars_with_colour("red"); Assert.IsTrue(regsNos.Count == 2 && regsNos.Contains("KA-01-ET-1111")); }
public void VacateCarTest() { Car[] cars = new Car[4] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, new Car { Color = "brown", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 4 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; Assert.IsTrue(Program.ParkingLot.Cars[2] != null); commands.leave("3"); Assert.IsTrue(Program.ParkingLot.Cars[2] == null); }
public void ParkCar_NegTest() { Car[] cars = new Car[5] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, null, new Car { Color = "brown", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 5 } }; sampleLot = new Model.ParkingLot(5) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; Assert.ThrowsException <BaseException>(() => commands.park("KA-01-ET-1111", "brown")) .ErrorMessage.Equals(ErrorMessage.CarAlreadyExists, StringComparison.InvariantCultureIgnoreCase); }
public void VacateCar_NegTest() { Car[] cars = new Car[4] { new Car { Color = "white", RegistrationNumber = "KA-01-HH-1234", SlotNumber = 1 }, new Car { Color = "red", RegistrationNumber = "KA-01-HH-9876", SlotNumber = 2 }, new Car { Color = "blue", RegistrationNumber = "KA-01-KH-1762", SlotNumber = 3 }, new Car { Color = "brown", RegistrationNumber = "KA-01-ET-1111", SlotNumber = 4 } }; sampleLot = new Model.ParkingLot(4) { Cars = cars }; ICommands commands = new CommandRouter(); Program.ParkingLot = sampleLot; Assert.ThrowsException <BaseException>(() => commands.leave("10")).ErrorMessage.Equals(ErrorMessage.SlotDoesNotExist); }
public ParkingLotService(Model.ParkingLot parkingLot) { _parkingLot = parkingLot; }