public void UnParkVehicleFromSlot_returns_Null_Happypath() { var vehicle1 = new Vehicle() { VehicleNumber = "KA-03-8986" }; var vehicle2 = new Vehicle() { VehicleNumber = "KA-03-8981" }; var vehicle3 = new Vehicle() { VehicleNumber = "KA-03-8982" }; var vehicle4 = new Vehicle() { VehicleNumber = "KA-03-8983" }; var vehicle5 = new Vehicle() { VehicleNumber = "KA-03-8984" }; IParkingManagement parkingMgmt = new ParkingManagement(5); parkingMgmt.AddVehicleToSlot(vehicle1); parkingMgmt.AddVehicleToSlot(vehicle2); parkingMgmt.AddVehicleToSlot(vehicle3); parkingMgmt.AddVehicleToSlot(vehicle4); parkingMgmt.AddVehicleToSlot(vehicle5); var t = parkingMgmt.UnParkVehicleFromSlot("KA-03-8987"); var vehicle = parkingMgmt.UnParkVehicleFromSlot(7); Assert.IsNull(vehicle); Assert.AreEqual(-1, t); }
public void AlocateCorrectSequence_returns_CorrectSlotNumber_Happypath() { var vehicle1 = new Vehicle() { VehicleNumber = "KA-03-8986" }; var vehicle2 = new Vehicle() { VehicleNumber = "KA-03-8981" }; var vehicle3 = new Vehicle() { VehicleNumber = "KA-03-8982" }; var vehicle4 = new Vehicle() { VehicleNumber = "KA-03-8983" }; var vehicle5 = new Vehicle() { VehicleNumber = "KA-03-8984" }; IParkingManagement parkingMgmt = new ParkingManagement(5); parkingMgmt.AddVehicleToSlot(vehicle1); parkingMgmt.AddVehicleToSlot(vehicle2); parkingMgmt.AddVehicleToSlot(vehicle3); parkingMgmt.AddVehicleToSlot(vehicle4); parkingMgmt.AddVehicleToSlot(vehicle5); var t = parkingMgmt.UnParkVehicleFromSlot("KA-03-8981"); var vehicle = parkingMgmt.UnParkVehicleFromSlot(4); Assert.AreEqual("KA-03-8983", vehicle.VehicleNumber); Assert.AreEqual(2, t); var vehicle6 = new Vehicle() { VehicleNumber = "KA-03-9982" }; var vehicle7 = new Vehicle() { VehicleNumber = "KA-03-9983" }; var vehicle8 = new Vehicle() { VehicleNumber = "KA-03-9984" }; var allocatedParking1 = parkingMgmt.AddVehicleToSlot(vehicle6); var allocatedParking2 = parkingMgmt.AddVehicleToSlot(vehicle7); Assert.AreEqual(2, allocatedParking1); Assert.AreEqual(4, allocatedParking2); parkingMgmt.UnParkVehicleFromSlot(1); var allocatedParking3 = parkingMgmt.AddVehicleToSlot(vehicle8); Assert.AreEqual(1, allocatedParking3); }