This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
using GrassyTerrainScript = PkmnLib.Plugin.Gen7.Scripts.Terrain.GrassyTerrain;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
|
||||
/// <summary>
|
||||
/// Tests for the <see cref="GrassyTerrain"/> move script.
|
||||
/// Gen VII Bulbapedia behavior (Generations VI to VII): "Grassy Terrain creates terrain that envelops the
|
||||
/// field and replaces the background environment and any other terrain that is already in effect."
|
||||
/// </summary>
|
||||
public class GrassyTerrainTests
|
||||
{
|
||||
private static (GrassyTerrain script, IExecutingMove move, IBattle battle) CreateTestSetup()
|
||||
{
|
||||
var script = new GrassyTerrain();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
move.User.Returns(user);
|
||||
|
||||
return (script, move, battle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: Grassy 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
|
||||
/// <see cref="GrassyTerrainScript"/> terrain script.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_SetsGrassyTerrainOnBattle()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, battle) = CreateTestSetup();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
battle.Received(1).SetTerrain(ScriptUtils.ResolveName<GrassyTerrainScript>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data on the user (outside of battle) the effect does nothing and
|
||||
/// does not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void OnSecondaryEffect_UserHasNoBattleData_DoesNotSetTerrain()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, battle) = CreateTestSetup();
|
||||
move.User.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
battle.DidNotReceiveWithAnyArgs().SetTerrain(default);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user