using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
///
/// Tests for the move script.
/// Gen VII Bulbapedia behavior: "Freeze Shock deals damage and has a 30% chance of paralyzing the target."
/// Freeze Shock is a two-turn move: the generic charge-turn handling lives in the shared base charge move
/// class, so these tests only cover the concrete logic of itself (its paralysis
/// secondary effect and the charge volatile it creates).
///
public class FreezeShockTests
{
///
/// Creates a fully mocked test setup for Freeze Shock secondary effect tests.
///
private static (FreezeShock script, IExecutingMove move, IBattlePokemon target, IBattlePokemon user, IBattleRandom
random) CreateTestSetup()
{
var script = new FreezeShock();
var move = Substitute.For();
var user = Substitute.For();
move.User.Returns(user);
var battle = Substitute.For();
var random = Substitute.For();
battle.Random.Returns(random);
var target = Substitute.For();
target.Battle.Returns(battle);
return (script, move, target, user, random);
}
///
/// Bulbapedia: "Freeze Shock deals damage and has a 30% chance of paralyzing the target."
/// When the effect chance roll succeeds, the target is paralyzed by the user.
///
[Test]
public async Task OnSecondaryEffect_EffectChanceSucceeds_ParalyzesTarget()
{
// Arrange
var (script, move, target, user, random) = CreateTestSetup();
random.EffectChance(30, move, target, 0).Returns(true);
// Act
script.OnSecondaryEffect(move, target, 0);
// Assert
target.Received(1).SetStatus(new StringKey("paralyzed"), user);
await Assert.That(target.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "SetStatus")).IsTrue();
}
///
/// Bulbapedia: "a 30% chance of paralyzing the target."
/// When the effect chance roll fails, the target is not paralyzed.
///
[Test]
public async Task OnSecondaryEffect_EffectChanceFails_DoesNotParalyzeTarget()
{
// Arrange
var (script, move, target, _, random) = CreateTestSetup();
random.EffectChance(30, move, target, 0).Returns(false);
// Act
script.OnSecondaryEffect(move, target, 0);
// Assert
await Assert.That(target.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "SetStatus")).IsFalse();
}
///
/// Bulbapedia: "a 30% chance of paralyzing the target."
/// The paralysis roll is made with exactly a 30% chance.
///
[Test]
public async Task OnSecondaryEffect_ParalysisRoll_UsesThirtyPercentChance()
{
// Arrange
var (script, move, target, _, random) = CreateTestSetup();
// Act
script.OnSecondaryEffect(move, target, 0);
// Assert
random.Received(1).EffectChance(30, move, target, 0);
await Assert.That(random.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "EffectChance")).IsTrue();
}
///
/// Bulbapedia: the user is "cloaked in a freezing light" on the charge turn and attacks on the following
/// turn. The concrete script provides the volatile that forces the user
/// to execute Freeze Shock on the second turn.
///
[Test]
public async Task CreateVolatile_ReturnsRequireChargeEffect()
{
// Arrange
var script = new FreezeShock();
var user = Substitute.For();
// Act
var chargeEffect = script.CreateVolatile(user);
// Assert
await Assert.That(chargeEffect).IsNotNull();
}
}