65 lines
2.2 KiB
C#
65 lines
2.2 KiB
C#
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Dynamic.ScriptHandling.Registry;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
using PsychicTerrainScript = PkmnLib.Plugin.Gen7.Scripts.Terrain.PsychicTerrain;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
|
|
|
/// <summary>
|
|
/// Tests for the <see cref="GenesisSupernova"/> move script.
|
|
/// Gen VII Bulbapedia behavior: "Genesis Supernova deals damage and causes the battlefield to become
|
|
/// Psychic Terrain for five turns."
|
|
/// </summary>
|
|
public class GenesisSupernovaTests
|
|
{
|
|
private static (GenesisSupernova script, IExecutingMove move, IBattle battle) CreateTestSetup()
|
|
{
|
|
var script = new GenesisSupernova();
|
|
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: Genesis Supernova "causes the battlefield to become Psychic Terrain" — the move sets
|
|
/// the battle's terrain to the <see cref="PsychicTerrainScript"/> terrain script.
|
|
/// </summary>
|
|
[Test]
|
|
public void OnSecondaryEffect_SetsPsychicTerrainOnBattle()
|
|
{
|
|
// Arrange
|
|
var (script, move, battle) = CreateTestSetup();
|
|
|
|
// Act
|
|
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
|
|
|
// Assert
|
|
battle.Received(1).SetTerrain(ScriptUtils.ResolveName<PsychicTerrainScript>());
|
|
}
|
|
|
|
/// <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);
|
|
}
|
|
} |