using PkmnLib.Dynamic.Models; using PkmnLib.Dynamic.ScriptHandling.Registry; using PkmnLib.Plugin.Gen7.Scripts.Moves; using ElectricTerrainScript = PkmnLib.Plugin.Gen7.Scripts.Terrain.ElectricTerrain; namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves; /// /// Tests for the move script. /// Gen VII Bulbapedia behavior (Generations VI to VII): Electric Terrain "envelops the field and replaces /// the background environment and any other terrain that is already in effect." /// public class ElectricTerrainTests { private static (ElectricTerrain script, IExecutingMove move, IBattle battle) CreateTestSetup() { var script = new ElectricTerrain(); var move = Substitute.For(); var battle = Substitute.For(); var battleData = Substitute.For(); battleData.Battle.Returns(battle); var user = Substitute.For(); user.BattleData.Returns(battleData); move.User.Returns(user); return (script, move, battle); } /// /// Bulbapedia: Electric Terrain "envelops the field and replaces the background environment and any /// other terrain that is already in effect" — the move sets the battle's terrain to the /// terrain script. /// [Test] public void OnSecondaryEffect_SetsElectricTerrainOnBattle() { // Arrange var (script, move, battle) = CreateTestSetup(); // Act script.OnSecondaryEffect(move, Substitute.For(), 0); // Assert battle.Received(1).SetTerrain(ScriptUtils.ResolveName()); } /// /// Technical test: without battle data on the user (outside of battle) the effect does nothing and /// does not throw. /// [Test] public void OnSecondaryEffect_UserHasNoBattleData_DoesNotSetTerrain() { // Arrange var (script, move, battle) = CreateTestSetup(); move.User.BattleData.Returns((IPokemonBattleData?)null); // Act script.OnSecondaryEffect(move, Substitute.For(), 0); // Assert battle.DidNotReceiveWithAnyArgs().SetTerrain(default); } }