public void should_park_to_parking_lot_with_higher_vacancy_rate( int parkingLot0Capacity, int parkingLot0OccupiedParkingSpace, int parkingLot1Capacity, int parkingLot1OccupiedParkingSpace, int chosenParkingLotIndex) { var parkingLot0 = new ParkingLotBuilder() .WithCapacity(parkingLot0Capacity) .WithOccupiedParkingSpace(parkingLot0OccupiedParkingSpace) .Create(); var parkingLot1 = new ParkingLotBuilder() .WithCapacity(parkingLot1Capacity) .WithOccupiedParkingSpace(parkingLot1OccupiedParkingSpace) .Create(); var parkingLots = new[] { parkingLot0, parkingLot1 }; var superParkingBoy = new SuperParkingBoy(parkingLots); var car = new Car(); var token = superParkingBoy.Park(car); var pickedCar = parkingLots[chosenParkingLotIndex].Pick(token); pickedCar.Should().BeSameAs(car); }
void should_not_park_car_by_super_boy_when_all_parking_lot_are_full() { var firstParkingLot = new ParkingLot(1); var secondParkingLot = new ParkingLot(1); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { firstParkingLot, secondParkingLot }); superParkingBoy.Park(new Car("Not care1")); ParkCarResult parkCarResult = superParkingBoy.Park(new Car("Not care2")); Assert.Equal(ParkCarResult.Success, parkCarResult); parkCarResult = superParkingBoy.Park(new Car("Not care3")); Assert.Equal(ParkCarResult.NoParkingSpace, parkCarResult); }
given_parking_boy_and_super_parking_boy_then_super_boy_can_not_manage_parking_boy() { var parkingLot = new OOParkingLot(1); var parkingBoy = new ParkingBoy(parkingLot); var superBoy = new SuperParkingBoy(parkingBoy as IParkingLot); superBoy.Park(new Car("car")); }
public void given_a_parkingLot_and_a_super_parking_boy_when_super_boy_park_a_car_then_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); Assert.AreSame(car, firstParkinglot.Pick(carId)); }
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_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_park_one_car_to_one_of_parking_lots_while_all_have_same_vacancy_rate() { var parkingLot = CreateParkingLotAndParkSomeCar(2, 1); var parkingLotWithSameRate = CreateParkingLotAndParkSomeCar(2, 1); var superParkingBoy = new SuperParkingBoy(new[] { parkingLot, parkingLotWithSameRate }); var car = new Car(); var carToken = superParkingBoy.Park(car); Assert.Same(car, CarParkingInOneOfParkingLots(new[] { parkingLot.Pick(carToken), parkingLotWithSameRate.Pick(carToken) })); }
public void given_a_parking_lot_and_a_super_parking_boy_which_managed_by_parking_manager_when_parking_boy_park_a_car_then_manager_could_pick_the_car() { var parkinglot = new OOParkingLot(1); var superParkingBoy = new SuperParkingBoy(parkinglot); var manager = new ParkingManager(superParkingBoy); var car = new Car("car"); var carId = superParkingBoy.Park(car); Assert.AreSame(car, manager.Pick(carId)); }
public void should_park_one_car_to_parking_lot_which_have_high_vacancy_rate_and_less_parking_space() { var parkingLotWithHighRate = CreateParkingLotAndParkSomeCar(3, 1); var parkingLotWithLowRate = CreateParkingLotAndParkSomeCar(6, 3); var superParkingBoy = new SuperParkingBoy(new[] { parkingLotWithHighRate, parkingLotWithLowRate }); var car = new Car(); var carToken = superParkingBoy.Park(car); Assert.Same(car, parkingLotWithHighRate.Pick(carToken)); }
public void should_park_car_when_there_is_one_parking_lot() { var parkingLot = new ParkingLot(1); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); var car = new Car(); var ticket = superParkingBoy.Park(car); Assert.Equal(car, parkingLot.Pick(ticket)); }
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_decrease_free_space_rate_when_park_car() { var parkingLot = new ParkingLot(2); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); var freeSpaceRateBeforePark = parkingLot.FreeSpaceRate; superParkingBoy.Park(new Car()); var freeSpaceRateAfterPark = parkingLot.FreeSpaceRate; Assert.True(freeSpaceRateBeforePark > freeSpaceRateAfterPark); }
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_not_park_car_when_parking_lot_is_0_free_space_rate() { var parkingLot = new ParkingLot(1); parkingLot.Park(new Car()); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLot }); var car = new Car(); var ticket = superParkingBoy.Park(car); Assert.Null(parkingLot.Pick(ticket)); }
void should_pick_the_car_from_parking_lots_when_park_a_car_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 = parkingLot.Pick(carId); Assert.Same(car, pickedCar); }
public void should_park_one_car_to_parking_lot_which_have_high_vacancy_rate_first_test() { var parkingLotWithHighRate = CreateParkingLotAndParkSomeCar(4, 1); var parkingLotWithLowRate = CreateParkingLotAndParkSomeCar(3, 1); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { parkingLotWithHighRate, parkingLotWithLowRate }); var car = new Car(); var carToken = superParkingBoy.Park(car); Assert.Same(car, parkingLotWithHighRate.Pick(carToken)); }
void should_park_car_to_the_parking_lot_which_has_the_larget_space_percent() { var lotPercent50 = new ParkingLot(2); lotPercent50.Park(new Car()); var lotPercent100 = new ParkingLot(1); var parkingBoy = new SuperParkingBoy(lotPercent50, lotPercent100); var car = new Car(); var token = parkingBoy.Park(car); var pickedCar = lotPercent100.Pick(token); Assert.Same(car, pickedCar); }
public void should_park_car_to_parking_lot_with_higher_free_rate() { var lowerFreeRateParkingLot = new ParkingLot(2); lowerFreeRateParkingLot.Park(new Car()); var higherFreeRateParkingLot = new ParkingLot(2); var superParkingBoy = new SuperParkingBoy(new List <ParkingLot> { lowerFreeRateParkingLot, higherFreeRateParkingLot }); var car = new Car(); var ticket = superParkingBoy.Park(car); Assert.Null(lowerFreeRateParkingLot.Pick(ticket)); Assert.Equal(car, higherFreeRateParkingLot.Pick(ticket)); }
void should_park_a_car_to_second_parking_lot_by_super_parking_boy_when_the_second_one_has_more_empty_parking_space_ratio() { var firstParkingLot = new ParkingLot(3); var secondParkingLot = new ParkingLot(1); var smartParkingBoy = new SuperParkingBoy(new List <ParkingLot> { firstParkingLot, secondParkingLot }); firstParkingLot.Park(new Car("notcare")); const string carId = "123"; var car = new Car(carId); smartParkingBoy.Park(car); Assert.Same(car, secondParkingLot.Pick(carId)); }
public void given_two_parkinglot_and_the_first_parkinglot_emptyRate_is_smaller_than_the_second_one_when_super_boy_park_a_car_then_the_second_parkinglot_could_pick_the_car() { var firstPrakingLot = new OOParkingLot(3); var secondPrakingLot = new OOParkingLot(4); var car = new Car("car"); var parkedCarInFirstParkingLot = new Car("car parked in the first parkinglot"); var parkedCarInSecondParkingLot = new Car("car parked in the second parkinglot"); firstPrakingLot.Park(parkedCarInFirstParkingLot); secondPrakingLot.Park(parkedCarInSecondParkingLot); var superBoy = new SuperParkingBoy(firstPrakingLot, secondPrakingLot); var carId = superBoy.Park(car); Assert.AreSame(car, secondPrakingLot.Pick(carId)); }
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); }
void should_pick_the_car_by_manager_when_park_a_car_by_parking_boy() { 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 }); parkingBoy.Park(car); Car pickedCar = manager.Pick(carId); Assert.Same(car, pickedCar); }