use of bwapi.UnitType 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.UnitType 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.UnitType in project BWJSAL by RobinsonMann.
the class UnitTypeSetup method setUpUnitTypes.
@SneakyThrows
public static void setUpUnitTypes() {
UnitType mockFirebat = mock(UnitType.class);
when(mockFirebat.toString()).thenReturn("Firebat");
setFinalStatic(bwapi.UnitType.class.getField("Terran_Firebat"), mockFirebat);
}
use of bwapi.UnitType in project BWJSAL by RobinsonMann.
the class BuildTimeTrackerTest method modifyUnitTypeToMock.
private void modifyUnitTypeToMock(final String unitTypeName, final Map<UnitType, Integer> requiredUnits) {
final UnitType mockDrone = Mockito.mock(UnitType.class);
when(mockDrone.toString()).thenReturn(unitTypeName);
when(mockDrone.requiredUnits()).thenReturn(requiredUnits);
setStaticFinalField(UnitType.class, unitTypeName, mockDrone);
}
use of bwapi.UnitType in project BWJSAL by RobinsonMann.
the class BuildTimeTrackerTest method enemyHasBuilt_mockEnemyRace_hasBuiltForCenterAndWorkersTrue.
@Test
public void enemyHasBuilt_mockEnemyRace_hasBuiltForCenterAndWorkersTrue() throws Exception {
final UnitType mockCenter = Mockito.mock(UnitType.class);
final UnitType mockWorker = Mockito.mock(UnitType.class);
final Race mockRace = createMockRace(mockCenter, mockWorker);
when(this.mockEnemy.getRace()).thenReturn(mockRace);
this.target.onStart();
assertEnemyHasBuilt(mockCenter, "Race's Center UnitType always built");
assertEnemyHasBuilt(mockWorker, "Race's Worker UnitType always built");
}
Aggregations