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 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); }