Beispiel #1
0
  @Test
  @Ignore("Implementation got lost")
  public void shouldStopWhenHitsWall() throws Exception {
    IWallE wallE = WallE.newInstance();

    IWheel oneWheel = mock(IWheel.class);
    wallE.setWheels(oneWheel, oneWheel);

    wallE.setBumper(new BumperStub());

    wallE.getWheels().forward(360);

    wallE.getBumper().setBumped(true);
    sleep(50);

    verify(oneWheel, times(2)).stop();
  }
Beispiel #2
0
  @Test
  // TODO needs refactoring
  public void wallETurnsRightWhenHitsWall() throws Exception {
    IWallE wallE = WallE.newInstance();

    IWheel oneWheel = mock(IWheel.class);
    wallE.setWheels(oneWheel, oneWheel);

    wallE.setBumper(new BumperStub());

    wallE.getWheels().forward(360);

    wallE.getBumper().setBumped(true);
    sleep(50);

    WallEsWheels wheels = mock(WallEsWheels.class);
    wheels.turn(1, 0, true, false);

    ArgumentCaptor<Double> noOfCircles = ArgumentCaptor.forClass(Double.class);
    ArgumentCaptor<Boolean> clockwise = ArgumentCaptor.forClass(Boolean.class);
    verify(wheels).turn(noOfCircles.capture(), anyInt(), clockwise.capture(), anyBoolean());
    assertEquals(1, noOfCircles.getValue().intValue());
    assertEquals(true, clockwise.getValue().booleanValue());
  }