-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bombard casualties firing back. (2.6 bug) (#11791)
A parameter was missing! Adds a test. Fixes: #8948
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...a/games/strategy/triplea/delegate/battle/steps/change/ClearBombardmentCasualtiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package games.strategy.triplea.delegate.battle.steps.change; | ||
|
||
import static games.strategy.triplea.delegate.battle.BattleState.Side.DEFENSE; | ||
import static games.strategy.triplea.delegate.battle.FakeBattleState.givenBattleStateBuilder; | ||
import static games.strategy.triplea.delegate.battle.steps.BattleStepsTest.givenAnyUnit; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
import games.strategy.engine.data.Unit; | ||
import games.strategy.engine.delegate.IDelegateBridge; | ||
import games.strategy.triplea.delegate.ExecutionStack; | ||
import games.strategy.triplea.delegate.battle.BattleActions; | ||
import games.strategy.triplea.delegate.battle.BattleState; | ||
import games.strategy.triplea.delegate.battle.steps.MockGameData; | ||
import java.util.List; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
public class ClearBombardmentCasualtiesTest { | ||
@Mock BattleActions battleActions; | ||
@Mock ExecutionStack executionStack; | ||
@Mock IDelegateBridge delegateBridge; | ||
|
||
@ParameterizedTest | ||
@ValueSource(booleans = {true, false}) | ||
void bombardCasualtiesRemoved(boolean navalBombardCasualtiesReturnFire) { | ||
final List<Unit> bombardingUnits = List.of(givenAnyUnit()); | ||
final List<Unit> attackers = List.of(givenAnyUnit()); | ||
final List<Unit> defenders = List.of(givenAnyUnit()); | ||
final MockGameData gameData = | ||
MockGameData.givenGameData() | ||
.withNavalBombardCasualtiesReturnFire(navalBombardCasualtiesReturnFire); | ||
final BattleState battleState = | ||
givenBattleStateBuilder() | ||
.battleRound(1) | ||
.bombardingUnits(bombardingUnits) | ||
.attackingUnits(attackers) | ||
.defendingUnits(defenders) | ||
.gameData(gameData.build()) | ||
.build(); | ||
|
||
final var clearBombardmentCasualties = | ||
new ClearBombardmentCasualties(battleState, battleActions); | ||
clearBombardmentCasualties.execute(executionStack, delegateBridge); | ||
if (!navalBombardCasualtiesReturnFire) { | ||
verify(battleActions).clearWaitingToDieAndDamagedChangesInto(delegateBridge, DEFENSE); | ||
} | ||
verifyNoMoreInteractions(battleActions); | ||
} | ||
} |