use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitTrackerTest method onDiscovery_unitDiscovered_unitTracked.
@Test
public void onDiscovery_unitDiscovered_unitTracked() {
final Unit unit = createMockUnit(true);
final Player unitOwner = Mockito.mock(Player.class);
when(unit.getPlayer()).thenReturn(unitOwner);
this.target.onUnitDiscover(unit, 0);
assertThat(this.target.getPlayer(unit)).isEqualTo(unitOwner);
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitTrackerTest method createMockUnit.
private Unit createMockUnit(final boolean exists) {
final Unit unit = Mockito.mock(Unit.class);
when(unit.exists()).thenReturn(exists);
return unit;
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class ReservedMapTest method canBuildHere_blockingTilesWereReservedAndFreed.
@Test
public void canBuildHere_blockingTilesWereReservedAndFreed() {
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);
// Reserve a tile that blocks building placement
this.target.reserveTiles(3, 3);
// Verify that tile does block placement
assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isFalse();
// Free blocking tile
this.target.freeTiles(3, 3);
// Verify that we can now place
assertThat(this.target.canBuildHere(builder, positionToBuild, typeToBuild)).isTrue();
verify(this.mockGame, times(2)).canBuildHere(positionToBuild, typeToBuild, builder);
verify(typeToBuild, times(2)).tileWidth();
verify(typeToBuild, times(2)).tileHeight();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitsMutexTest method unlockUnit_unitNotLocked_unitStillUnlocked.
@Test
public void unlockUnit_unitNotLocked_unitStillUnlocked() {
final Unit unit = UnitBuilder.mockUnit();
assertThat(this.target.isUnitLocked(unit)).as("Sanity test that unit unlocked").isFalse();
this.target.unlockUnit(unit);
assertThat(this.target.isUnitLocked(unit)).as("unit still unlocked").isFalse();
}
use of bwapi.Unit in project BWJSAL by RobinsonMann.
the class UnitsMutexTest method isUnitFree_unitIsFree_returnsTrue.
@Test
public void isUnitFree_unitIsFree_returnsTrue() {
final Unit unit = UnitBuilder.mockUnit();
assertThat(this.target.isUnitFree(unit)).isTrue();
}
Aggregations