Example #1
0
  /** Tests setting a normal bank */
  @Test
  public void testSetBank() {
    World mockWorld = mock(World.class);
    Player mockPlayer = mock(Player.class);
    Delayer delayer = mock(Delayer.class);
    Robot TU = new Robot(mockWorld, delayer, new Bank[] {null, null}, "Test Robot", mockPlayer);

    Bank testBank = mock(Bank.class);
    TU.setBank(testBank, 0, false);

    assertSame(TU.getBank(0), testBank, "Bank set was the same");
  }
Example #2
0
  /** Tests setting a null bank */
  @Test
  public void testSetNullBank() {
    World mockWorld = mock(World.class);
    Player mockPlayer = mock(Player.class);
    Delayer delayer = mock(Delayer.class);
    Robot TU =
        new Robot(
            mockWorld,
            delayer,
            new Bank[] {new ChangerBank(), new ChangerBank()},
            "Test Robot",
            mockPlayer);

    TU.setBank(null, 0, false);

    assertNull(TU.getBank(0), "Bank set was the same");
  }
Example #3
0
  /** Tests whether reverse transferring a null bank succeeds */
  @Test
  public void testReverseNullTransfer() {
    World mockWorld = mock(World.class);
    Player mockPlayer = mock(Player.class);
    Delayer delayer = mock(Delayer.class);
    ChangerBank bank = new ChangerBank();
    Robot TU = new Robot(mockWorld, delayer, new Bank[] {null, bank}, "Test Robot", mockPlayer);

    Robot target =
        new Robot(mockWorld, delayer, new Bank[] {bank, null}, "Robot target", mockPlayer);

    when(mockWorld.getNeighbour(TU)).thenReturn(target);

    TU.reverseTransfer(1, 1);

    assertNull(TU.getBank(1), "Target bank not transferred");
  }
Example #4
0
  /** Tests transferring a normal bank */
  @Test
  public void testTransfer() {
    World mockWorld = mock(World.class);
    Player mockPlayer = mock(Player.class);
    Delayer delayer = mock(Delayer.class);
    ChangerBank bank = new ChangerBank();
    Robot TU = new Robot(mockWorld, delayer, new Bank[] {bank, null}, "Test Robot", mockPlayer);

    Robot target =
        new Robot(mockWorld, delayer, new Bank[] {null, null}, "Robot target", mockPlayer);

    when(mockWorld.getNeighbour(TU)).thenReturn(target);

    TU.transfer(0, 1);

    assertEquals(target.getBank(1).getClass(), bank.getClass(), "Target bank not transferred");
  }