コード例 #1
0
  @Test
  public void should_success_to_park_car_when_two_parkinglot_both_empty() {
    ParkingBoy smartParkingBoy =
        ParkingBoy.smartParkingBoy(Arrays.asList(new ParkingLot(1), new ParkingLot(1)));

    Car car = new Car(CAR_LICENSE);
    UUID ticket = smartParkingBoy.park(car);

    assertEquals(car, smartParkingBoy.pick(ticket));
  }
コード例 #2
0
  @Test
  public void should_success_to_pick_car_when_parked_a_car_in_one_parkinglot_with_one_capacity() {
    ParkingBoy smartParkingBoy =
        ParkingBoy.smartParkingBoy(Collections.singletonList(new ParkingLot(1)));

    Car car = new Car(CAR_LICENSE);
    UUID ticket = smartParkingBoy.park(car);

    assertEquals(car, smartParkingBoy.pick(ticket));
  }
コード例 #3
0
  @Test
  public void should_fail_to_park_car_when_two_parkinglot_both_full() {
    // given
    ParkingBoy smartParkingBoy =
        ParkingBoy.smartParkingBoy(Arrays.asList(new ParkingLot(0), new ParkingLot(0)));

    // when
    Car car = new Car(CAR_LICENSE);

    // then
    assertNull(smartParkingBoy.park(car));
  }
コード例 #4
0
  @Test
  public void should_fail_to_park_car_when_one_parkinglot_with_one_capacity_occupied() {
    ParkingLot parkingLot =
        new ParkingLot(1) {
          {
            park(new Car(ANOTHER_CAR_LICENSE));
          }
        };
    ParkingBoy smartParkingBoy = ParkingBoy.smartParkingBoy(Collections.singletonList(parkingLot));

    Car car = new Car(CAR_LICENSE);

    assertNull(smartParkingBoy.park(car));
  }
コード例 #5
0
  @Test
  public void should_success_to_park_car_in_first_parkinglot_when_two_parkinglot_both_one_space() {
    // given
    ParkingLot oneSpaceParkinglot = new ParkingLot(1);
    ParkingLot anotherOneSpaceParkinglot = new ParkingLot(1);
    ParkingBoy smartParkingBoy =
        ParkingBoy.smartParkingBoy(Arrays.asList(oneSpaceParkinglot, anotherOneSpaceParkinglot));

    // when
    Car car = new Car(CAR_LICENSE);
    UUID ticket = smartParkingBoy.park(car);

    // then
    assertEquals(car, oneSpaceParkinglot.pick(ticket));
  }
コード例 #6
0
  @Test
  public void
      should_success_to_park_at_second_when_two_parkinglot_first_has_one_space_second_has_two() {
    // given
    ParkingLot oneSpaceParkinglot = new ParkingLot(1);
    ParkingLot twoSpaceParkingLot = new ParkingLot(2);
    ParkingBoy smartParkingBoy =
        ParkingBoy.smartParkingBoy(Arrays.asList(oneSpaceParkinglot, twoSpaceParkingLot));

    // when
    Car car = new Car(CAR_LICENSE);
    UUID ticket = smartParkingBoy.park(car);

    // then
    assertEquals(car, twoSpaceParkingLot.pick(ticket));
  }