예제 #1
0
  @Test
  public void activateVehicleTest() throws Exception {

    // When
    vehicle.activate();

    // Then
    List<Event> events = vehicle.getPendingEvents();
    assertTrue(events.size() == 1);
    assertTrue(events.get(0).equals(new Activated(vehicle.id)));
  }
예제 #2
0
  @Test(expected = IllegalStateException.class)
  public void activateActiveVehicle() throws Exception {

    // Given
    vehicle.applyEvent(new Activated(vehicle.id));

    // When
    vehicle.activate();

    // Should throw IllegalStateException
  }
예제 #3
0
  @Test
  public void moveActiveVehicleTest() throws Exception {

    // Given
    vehicle.applyEvent(new Activated(vehicle.id));

    // When
    vehicle.changeLocation(1f, 1f);

    // Then
    List<Event> events = vehicle.getPendingEvents();
    assertTrue(events.size() == 2);
    assertTrue(events.get(1).equals(new LocationChanged(1f, 1f)));
  }
예제 #4
0
  @Test(expected = IllegalStateException.class)
  public void moveInactiveVehicleTest() throws Exception {

    // When
    vehicle.changeLocation(1f, 1f);

    // Should throw IllegalStateException
  }
예제 #5
0
  // ex09 test
  @Test
  public void testGetMaxID() {
    // setup
    Vehicle vehicle1 = new Vehicle();
    Vehicle vehicle2 = new Vehicle();

    // execute
    int actual = Vehicle.getMaxID();

    // test
    assertEquals(1, actual);
  }
예제 #6
0
  @Test
  public void testTurnBoolean() {
    // setup
    Vehicle vehicle = new Vehicle();
    vehicle.setAngle(0);
    vehicle.setOwner("hoge");
    vehicle.setSpeed(60);

    // execute
    vehicle.turn(Vehicle.TURN_LEFT);
    double actual = vehicle.getAngle();

    // test
    assertEquals(90.0, actual, 0.1);
  }
예제 #7
0
  @Test
  public void testStop() {
    // setup
    Vehicle vehicle = new Vehicle();
    vehicle.setAngle(0);
    vehicle.setOwner("hoge");
    vehicle.setSpeed(60);

    // execute
    vehicle.stop();
    double actual = vehicle.getSpeed();

    // test
    assertTrue(0.0 == actual);
  }
예제 #8
0
  // ex15 test
  @Test
  public void testChangeSpeed() {
    // setup
    Vehicle vehicle = new Vehicle();
    vehicle.setAngle(0);
    vehicle.setOwner("hoge");
    vehicle.setSpeed(60);

    // execute
    vehicle.changeSpeed(12.34);
    double actual = vehicle.getSpeed();

    // test
    assertEquals(12.34, actual, 0.01);
  }
예제 #9
0
 // gasがない場合startできない
 @Test
 public void startTestZeroGas() {
   Vehicle v1 = new Vehicle(0, 10);
   assertFalse(v1.start());
 }
예제 #10
0
 // 両方ある場合startできる
 @Test
 public void startTest() {
   Vehicle v1 = new Vehicle(10, 10);
   assertTrue(v1.start());
 }
예제 #11
0
 // batteryがない場合startできない
 @Test
 public void startTestzeroBattery() {
   Vehicle v1 = new Vehicle(10, 0);
   assertFalse(v1.start());
 }