use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitTrackerTest method onFrame_propertyChangedSinceDiscovery_latestPropertyReturned.
@Test
public void onFrame_propertyChangedSinceDiscovery_latestPropertyReturned() {
final Unit unit = createMockUnit(true);
final Player originalUnitOwner = Mockito.mock(Player.class);
when(unit.getPlayer()).thenReturn(originalUnitOwner);
this.target.onUnitDiscover(unit, 0);
// Owner has changed and unit still exists, so tracked owner should change at next onFrame()
final Player newUnitOwner = Mockito.mock(Player.class);
when(unit.getPlayer()).thenReturn(newUnitOwner);
this.target.onFrame(1);
assertThat(this.target.getPlayer(unit)).isEqualTo(newUnitOwner);
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitTrackerTest method unitDestroyed_unitDestroyed_existsIsFalse.
@Test
public void unitDestroyed_unitDestroyed_existsIsFalse() {
final Unit unit = createMockUnit(true);
this.target.onUnitDiscover(unit, 1);
this.target.onFrame(1);
this.target.onFrame(2);
when(unit.exists()).thenReturn(false);
this.target.onUnitDestroy(unit, 2);
this.target.onFrame(3);
assertThat(this.target.doesUnitExist(unit)).isFalse();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class ReservedMapTest method canBuildHere_gameCanBuildHereFalse.
@Test
public void canBuildHere_gameCanBuildHereFalse() {
final TilePosition positionToBuild = new TilePosition(2, 2);
final Unit builder = Mockito.mock(Unit.class);
final UnitType typeToBuild = Mockito.mock(UnitType.class);
verifyNoMoreInteractions(typeToBuild);
when(this.mockGame.canBuildHere(positionToBuild, typeToBuild, builder)).thenReturn(false);
assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isFalse();
verify(this.mockGame).canBuildHere(positionToBuild, typeToBuild, builder);
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class ReservedMapTest method canBuildHere_partialTilesReserved.
@Test
public void canBuildHere_partialTilesReserved() {
final TilePosition positionToBuild = new TilePosition(2, 2);
final Unit builder = Mockito.mock(Unit.class);
final UnitType typeToBuild = Mockito.mock(UnitType.class);
when(typeToBuild.tileWidth()).thenReturn(2);
when(typeToBuild.tileHeight()).thenReturn(2);
when(this.mockGame.canBuildHere(positionToBuild, typeToBuild, builder)).thenReturn(true);
this.target.reserveTiles(3, 3);
assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isFalse();
verify(this.mockGame).canBuildHere(positionToBuild, typeToBuild, builder);
verify(typeToBuild, times(1)).tileWidth();
verify(typeToBuild, times(1)).tileHeight();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitsMutexTest method isUnitUnlocked_unitIsFree_returnsTrue.
@Test
public void isUnitUnlocked_unitIsFree_returnsTrue() {
final Unit unit = UnitBuilder.mockUnit();
assertThat(this.target.isUnitUnlocked(unit)).isTrue();
}
Aggregations