public void More_test_cases_SuperSmartParkingBoy_Should_park_cars_to_more_positionRate_parkingLot(int parkingCapacity1, int parkingCapacity2, int parkingCapacity3) { //given var parkingLots = new List <ParkingLot>() { { new ParkingLot(parkingCapacity1) }, { new ParkingLot(parkingCapacity2) }, { new ParkingLot(parkingCapacity3) } }; var superSmartParkingBoy = new SuperSmartParkingBoy(); var parkingBoy = new ParkingBoy(); //when for (int i = 0; i < 2; i++) { parkingBoy.Park(i.ToString(), parkingLots[1]); parkingBoy.Park(i.ToString(), parkingLots[2]); } var numberPlate = "XX2345"; var parkingTicket = superSmartParkingBoy.Park(numberPlate, parkingLots); var expectParkingLot = parkingLots[0]; //then Assert.NotEmpty(parkingTicket); Assert.Contains <string>("XX2345", expectParkingLot.ParkingCarsList); }
public void should_can_pack_one_car_when_parking_boy_has_one_full_packinglot_and_unfull_packinglot() { var secondParkingLot = new ParkingLot(1); var parkingBoy = new ParkingBoy(new List <ParkingLot> { new ParkingLot(1), secondParkingLot }); parkingBoy.Park(new Car()); var car = new Car(); var carId = parkingBoy.Park(car); Assert.AreSame(car, secondParkingLot.Pick(carId)); }
public void should_get_null_if_try_to_park_a_car_when_all_parking_lots_are_full() { var parkingLot1 = new ParkingLot(1); var parkingLot2 = new ParkingLot(1); var parkingBoy = new ParkingBoy(new List <ParkingLot>() { parkingLot1, parkingLot2 }); parkingBoy.Park(new Car()); parkingBoy.Park(new Car()); Assert.Null(parkingBoy.Park(new Car())); }
public void should_return_same_car_when_use_second_parking_lot_pick_car() { var secondParkingLot = new ParkingLot(2); var smartParkingBoy = new ParkingBoy(new List <ParkingLot> { new ParkingLot(2), secondParkingLot }, ParkingBoyType.Smart); smartParkingBoy.Park(new Car()); Car car = new Car(); var carId = smartParkingBoy.Park(car); Assert.AreSame(car, secondParkingLot.Pick(carId)); }
public void Should_Return_no_parkingTicket_when_park_a_parked_car() { //given var parkingLot = new ParkingLot(); var parkingBoy = new ParkingBoy(); //when string numberPlate = "XX2345"; parkingBoy.Park(numberPlate, parkingLot); var actual = parkingBoy.Park(numberPlate, parkingLot); //then Assert.Empty(actual); }
public void should_pick_corresponding_car_with_specific_ticket() { List <ParkingLot> parkingLots = new List <ParkingLot>() { new ParkingLot(2) }; ParkingBoy parkingBoy = new ParkingBoy(parkingLots); Car carA = new Car(); Car carB = new Car(); var ticketA = parkingBoy.Park(carA); var ticketB = parkingBoy.Park(carB); Assert.Same(carA, parkingBoy.Pick(ticketA)); Assert.Same(carB, parkingBoy.Pick(ticketB)); }
void should_pick_the_car_when_the_first_parking_lot_is_full_and_park_the_car() { var parkingBoy = new ParkingBoy(new List <ParkingLot> { new ParkingLot(1), new ParkingLot(1) }); const string carId = "ABC123"; var car = new Car(carId); parkingBoy.Park(new Car("not care")); parkingBoy.Park(car); Car pickedCar = parkingBoy.Pick(carId); Assert.Same(car, pickedCar); }
public void should_keep_order_when_make_park_boy_park_a_car_given_boy_own_two_parking_lot_first_parking_lot_has_two_spaces() { var firsLot = new ParkingLot(2); var secondLot = new ParkingLot(0); var lots = new List <ParkingLot> { firsLot, secondLot }; var boy = new ParkingBoy(lots); boy.Park(new Car()); boy.Park(new Car()); Assert.Equal(2, firsLot.CurrentCount()); Assert.Equal(0, secondLot.CurrentCount()); }
public void Should_ParkingBoy_Return_Null_When_Both_Parkinglots_Are_Full(string plateNumber, string parkingTicket) { //Given var boy = new ParkingBoy("Jack"); var car = new Car(plateNumber); string message = string.Empty; var parkingLots = new List <CarLot <string, Car> >() { LotInitialize.FillLotWithCars(10), LotInitialize.FillLotWithCars(10), }; string expectedTicket = null; int expectedLoadsOfFirstParkinglot = 10; int expectedLoadsOfSecondParkinglot = 10; //When string actualTicket = boy.Park(car, parkingLots, out message); var actualLoadsOfFirstParkinglot = parkingLots[0].Count; var actualLoadsOfSecondParkinglot = parkingLots[1].Count; //Then Assert.Equal(expectedTicket, actualTicket); Assert.Equal(expectedLoadsOfFirstParkinglot, actualLoadsOfFirstParkinglot); Assert.Equal(expectedLoadsOfSecondParkinglot, actualLoadsOfSecondParkinglot); }
void should_not_park_car_when_all_parking_lot_are_full() { var firstParkingLot = new ParkingLot(1); var secondParkingLot = new ParkingLot(1); var parkingBoy = new ParkingBoy(new List <ParkingLot> { firstParkingLot, secondParkingLot }); parkingBoy.Park(new Car("Not care1")); ParkCarResult parkCarResult = parkingBoy.Park(new Car("Not care2")); Assert.Equal(ParkCarResult.Success, parkCarResult); parkCarResult = parkingBoy.Park(new Car("Not care3")); Assert.Equal(ParkCarResult.NoParkingSpace, parkCarResult); }
void should_park_the_car_in_the_secondary_parking_lot_when_the_first_one_is_full() { var firstParkingLot = new ParkingLot(1); var secondParkingLot = new ParkingLot(1); var parkingBoy = new ParkingBoy(new List <ParkingLot> { firstParkingLot, secondParkingLot }); const string carId = "ABC123"; var car = new Car(carId); parkingBoy.Park(new Car("Not care")); parkingBoy.Park(car); Car pickedCar = secondParkingLot.Pick(carId); Assert.Same(car, pickedCar); }
void should_return_error_message_when_given_a_car_to_parking_boy_while_parking_lots_are_full() { var parkingBoy = new ParkingBoy(new List <ParkingLot> { new ParkingLot(parkingLotSize), new ParkingLot(parkingLotSize) }); for (var i = 0; i < parkingLotSize * 2; i++) { parkingBoy.Park(new Car()); } var error = Assert.Throws <Exception>(() => parkingBoy.Park(new Car())); Assert.Equal("Parking lots are full!", error.Message); }
public void Should_Return_Null_Tickt_When_Park_The_Parked_Car() { //given var parkingBoy = new ParkingBoy(new List <ParkingLot>() { new ParkingLot() }); var car = new Car("car1"); parkingBoy.Park(car, out _); //when var ticket = parkingBoy.Park(car, out _); //then Assert.Null(ticket); }
public void Should_Park_The_Car_To_Mutiple_Parking_Lots_And_Park_To_Next_One_If_Previous_Is_Full() { //given var parkingLot2 = new ParkingLot(2); var parkingBoy = new ParkingBoy(new List <ParkingLot>() { new ParkingLot(1), parkingLot2 }); //when var ticket1 = parkingBoy.Park(new Car("car1"), out _); var ticket2 = parkingBoy.Park(new Car("car2"), out _); //then Assert.Contains(ticket2.TicketNumber, parkingLot2.Tickets); }
public void Car_Should_not_be_parked_if_parkinglot_is_full() { //given var parkingLot = new ParkingLot(); var parkingBoy = new ParkingBoy(); //when var numberPlate = "XX2345"; for (int i = 0; i < 10; i++) { parkingBoy.Park(i.ToString(), parkingLot); } var actual = parkingBoy.Park(numberPlate, parkingLot); //then Assert.Empty(actual); }
void should_can_not_pick_the_same_car_twice() { var parkingBoy = new ParkingBoy(new ParkingLot(10)); var token = parkingBoy.Park(new Car()); parkingBoy.Pick(token); Assert.Throws <NotFoundException>(() => parkingBoy.Pick(token)); }
public void Should_Park_No_Car_Given_Parking_Lot_Has_No_Position() { //given var parkedCar = new Car("N98245"); var parkingBoy = new ParkingBoy(new List <ParkingLot>() { new ParkingLot(1) }); parkingBoy.Park(parkedCar, out _); //when var newCar = new Car("A982453"); var newTicket = parkingBoy.Park(newCar, out _); //then Assert.Null(newTicket); }
void should_return_a_ticket_when_given_a_car_to_parking_boy() { var parkingBoy = new ParkingBoy(new List <ParkingLot> { new ParkingLot(parkingLotSize) }); var ticket = parkingBoy.Park(new Car()); Assert.NotNull(ticket); }
void should_return_error_message_when_given_a_car_to_parking_boy_while_parking_lots_managed_by_him_are_full() { var notManagedParkingLot = new ParkingLot(parkingLotSize); var managedParkingLot = new ParkingLot(parkingLotSize); var parkingBoy = new ParkingBoy(new List <ParkingLot> { managedParkingLot }); for (var i = 0; i < parkingLotSize; i++) { parkingBoy.Park(new Car()); } Assert.NotNull(notManagedParkingLot.Park(new Car())); var error = Assert.Throws <Exception>(() => parkingBoy.Park(new Car())); Assert.Equal("Parking lots are full!", error.Message); }
void should_can_pick_the_car_by_parking_boy_when_parking_boy_park_a_car() { var parkingBoy = new ParkingBoy(new ParkingLot(10)); var car = new Car(); var token = parkingBoy.Park(car); var pickedCar = parkingBoy.Pick(token); Assert.Same(car, pickedCar); }
public void should_park_cars_in_order_using_multiple_parking_lot() { var car1 = new Car(); var car2 = new Car(); var parkingLot1 = new ParkingLot(1); var parkingLot2 = new ParkingLot(1); var parkingBoy = new ParkingBoy(new List <ParkingLot>() { parkingLot1, parkingLot2 }); var ticket1 = parkingBoy.Park(car1); var ticket2 = parkingBoy.Park(car2); Assert.Null(parkingLot1.Pick(ticket2)); Assert.Null(parkingLot2.Pick(ticket1)); Assert.Equal(car1, parkingLot1.Pick(ticket1)); Assert.Equal(car2, parkingLot2.Pick(ticket2)); }
public void should_park_one_car() { var parkingLot = new ParkingLot(4); var parkingBoy = new ParkingBoy(new[] { parkingLot }); var car = new Car(); var token = parkingBoy.Park(car); Assert.Same(car, parkingLot.Pick(token)); }
public void should_throw_NoSpaceException_when_make_park_boy_park_a_car_given_parking_lot_no_space() { var parkingLot = new ParkingLot(0); var boy = new ParkingBoy(new List <ParkingLot> { parkingLot }); var exception = Assert.Throws <NoSpaceException>(() => boy.Park(new Car())); Assert.Equal("no space", exception.Message); }
public void should_return_ticket_when_make_park_boy_park_a_car_given_parking_lot_has_only_one_space() { var parkingLot = new ParkingLot(1); var boy = new ParkingBoy(new List <ParkingLot> { parkingLot }); var ticket = boy.Park(new Car()); Assert.NotNull(ticket); }
public void should_return_car_when_make_park_boy_pick_a_car_given_a_correct_ticket() { var parkingLot = new ParkingLot(1); var boy = new ParkingBoy(new List <ParkingLot> { parkingLot }); var car = new Car(); var ticket = boy.Park(car); Assert.Equal(car, boy.Pick(ticket)); }
public void Should_ParkingBoyPark_Return_No_Ticket_Given_Parked_Car() { //Given var boy = new ParkingBoy("Jack"); string message = string.Empty; var parkingLots = new List <CarLot <string, Car> >() { LotInitialize.FillLotWithCars(3), }; var car = new Car("RJ_12784"); boy.Park(car, parkingLots, out message); string expected = null; //When var result = boy.Park(car, parkingLots, out message); //Then Assert.Equal(expected, result); }
public void Return_a_parkingTicket_when_park() { //given var parkingLot = new ParkingLot(); var parkingBoy = new ParkingBoy(); //when var numberPlate = "XX2345"; //then Assert.IsType <string>(parkingBoy.Park(numberPlate, parkingLot)); }
void should_can_pick_the_car_from_the_first_has_space_parking_lot() { var parkingLot = new ParkingLot(10); var parkingBoy = new ParkingBoy(new ParkingLot(0), parkingLot, new ParkingLot(10)); var car = new Car(); var token = parkingBoy.Park(car); var pickedCar = parkingLot.Pick(token); Assert.Same(car, pickedCar); }
public void should_park_a_car_into_a_parking_lot_which_has_space_and_get_a_ticket() { var list = new List <ParkingLot> { new ParkingLot(_capacity) }; var parkingBoy = new ParkingBoy(list); var ticket = parkingBoy.Park(new Car()); Assert.NotNull(ticket); }
public void Sould_return_something_when_park() { //given var parkingLot = new ParkingLot(); var parkingBoy = new ParkingBoy(); //when var numberPlate = "XX2345"; //then Assert.NotNull(parkingBoy.Park(numberPlate, parkingLot)); }