void should_can_pick_the_car_when_manage_parking_lots_and_parking_boys_and_park_a_car() { var lotNoSpace = new ParkingLot(0); var lotHasSpace = new ParkingLot(2); var boy = new SuperParkingBoy(lotHasSpace); var superBoy = new SuperParkingBoy(lotHasSpace); var smartBoy = new SuperParkingBoy(lotNoSpace); var manager = new ParkingManager(lotNoSpace, boy, smartBoy, superBoy); var car = new Car(); var token = manager.Park(car); Assert.Same(car, manager.Pick(token)); token = manager.Park(car); Assert.Same(car, boy.Pick(token)); token = manager.Park(car); Assert.Same(car, superBoy.Pick(token)); token = manager.Park(car); Assert.Same(car, lotHasSpace.Pick(token)); token = manager.Park(car); Assert.Throws <NotFoundException>(() => smartBoy.Pick(token)); token = manager.Park(car); Assert.Throws <NotFoundException>(() => lotNoSpace.Pick(token)); }
void should_not_pick_a_car_when_the_car_has_been_picked_by_super_parking_boy() { const string carId = "ABC123"; var car = new Car(carId); var parkingLot = new ParkingLot(); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); superParkingBoy.Park(car); Car pickedCar = superParkingBoy.Pick(carId); Assert.Same(car, pickedCar); pickedCar = superParkingBoy.Pick(carId); Assert.Null(pickedCar); }
public void should_not_pick_correct_car_while_no_parking() { var parkingLotWithHighVacancyRate = CreateParkingLotAndParkSomeCar(4, 1); var parkingLotWithLowVacancyRate = CreateParkingLotAndParkSomeCar(3, 1); var superParkingBoy = new SuperParkingBoy(new[] { parkingLotWithHighVacancyRate, parkingLotWithLowVacancyRate }); const int illegalCarToken = 0; Assert.Same(null, superParkingBoy.Pick(illegalCarToken)); }
void should_can_pick_the_car_when_parking_boy_park_a_car() { var parkingBoy = new SuperParkingBoy(new ParkingLot(10)); var car = new Car(); var token = parkingBoy.Park(car); var pickedCar = parkingBoy.Pick(token); Assert.Same(car, pickedCar); }
public void should_pick_correct_car() { var parkingLotWithHighVacancyRate = CreateParkingLotAndParkSomeCar(5, 1); var parkingLotWithLowVacancyRate = CreateParkingLotAndParkSomeCar(3, 1); var superParkingBoy = new SuperParkingBoy(new[] { parkingLotWithHighVacancyRate, parkingLotWithLowVacancyRate }); var car = new Car(); var carToken = parkingLotWithHighVacancyRate.Park(car); Assert.Same(car, superParkingBoy.Pick(carToken)); }
public void given_a_parkingLot_and_a_super_parking_boy_when_super_park_a_car_then_super_boy_pick_the_car_in_the_parkingLot() { var firstParkinglot = new OOParkingLot(1); var superParkingBoy = new SuperParkingBoy(firstParkinglot); var car = new Car("car"); var carId = superParkingBoy.Park(car); var pickedCar = superParkingBoy.Pick(carId); Assert.AreSame(car, pickedCar); }
public void should_pick_the_same_car_after_parked_it() { var parkingLot = new ParkingLot(1); var superParkingBoy = new SuperParkingBoy(parkingLot); var car = new Car(); var token = superParkingBoy.Park(car); var pickedCar = superParkingBoy.Pick(token); pickedCar.Should().BeSameAs(car); }
public void should_be_able_to_park_car_if_parking_lots_has_same_free_space_rate() { var parkingLot1 = new ParkingLot(1); var parkingLot2 = new ParkingLot(1); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot1, parkingLot2 }); var car = new Car(); var ticket = superParkingBoy.Park(car); Assert.Equal(car, superParkingBoy.Pick(ticket)); }
public void should_be_able_to_pick_car() { var car = new Car(); var parkingLot = new ParkingLot(1); var parkingBoy = new SuperParkingBoy(new List <ParkingLot>() { parkingLot }); var ticket = parkingLot.Park(car); Assert.Equal(car, parkingBoy.Pick(ticket)); }
public void should_increase_free_space_rate_when_pick_car() { var parkingLot = new ParkingLot(2); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); var ticket = superParkingBoy.Park(new Car()); var freeSpaceRateBeforePick = parkingLot.FreeSpaceRate; superParkingBoy.Pick(ticket); var freeSpaceRateAfterPick = parkingLot.FreeSpaceRate; Assert.True(freeSpaceRateBeforePick < freeSpaceRateAfterPick); }
public void should_pick_car_from_parking_lot_2_if_the_car_is_in_parking_lot_2() { var parkingLot1 = new ParkingLot(1); var parkingLot2 = new ParkingLot(1); var parkingBoy = new SuperParkingBoy(new List <ParkingLot>() { parkingLot1, parkingLot2 }); var car = new Car(); var ticket = parkingLot2.Park(car); Assert.Equal(car, parkingBoy.Pick(ticket)); }
given_a_smart_boy_with_empty_parking_lot_and_a_super_boy_with_one_space_parking_lot_both_managed_by_parking_manager_when_parking_manager_park_the_car_then_super_boy_could_pick_the_car () { var emptyParkinglot = new OOParkingLot(0); var parkinglot = new OOParkingLot(1); var smartBoy = new SmartParkingBoy(emptyParkinglot); var superBoy = new SuperParkingBoy(parkinglot); var manager = new ParkingManager(smartBoy, superBoy); var car = new Car("car"); var carId = manager.Park(car); Assert.AreSame(car, superBoy.Pick(carId)); }
void should_pick_the_car_by_super_parking_boy_when_park_a_car_to_parking_lot() { const string carId = "ABC123"; var car = new Car(carId); var parkingLot = new ParkingLot(); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); parkingLot.Park(car); Car pickedCar = superParkingBoy.Pick(carId); Assert.Same(car, pickedCar); }
void should_pick_the_car_by_parking_boys_when_park_a_car_by_manager() { const string carId = "ABC123"; var car = new Car(carId); var parkingLot = new ParkingLot(); var parkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); var manager = new Manager(new List <IPickerParker> { parkingBoy }); manager.Park(car); Car pickedCar = parkingBoy.Pick(carId); Assert.Same(car, pickedCar); }