Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -20,12 +20,12 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class BounceTests
|
||||
{
|
||||
private static (Bounce script, IExecutingMove move, IPokemon user, ScriptSet userVolatile, IMoveChoice moveChoice,
|
||||
IBattleRandom random) CreateTestSetup()
|
||||
private static (Bounce script, IExecutingMove move, IBattlePokemon user, ScriptSet userVolatile, IMoveChoice
|
||||
moveChoice, IBattleRandom random) CreateTestSetup()
|
||||
{
|
||||
var script = new Bounce();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
// Use a real script set so the charge volatile added by Bounce can be inspected afterwards.
|
||||
var userVolatile = new ScriptSet(user);
|
||||
user.Volatile.Returns(userVolatile);
|
||||
@@ -39,9 +39,7 @@ public class BounceTests
|
||||
var random = Substitute.For<IBattleRandom>();
|
||||
battle.Random.Returns(random);
|
||||
battle.EventHook.Returns(new EventHook());
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
return (script, move, user, userVolatile, moveChoice, random);
|
||||
}
|
||||
@@ -148,7 +146,7 @@ public class BounceTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, user, _, _, random) = CreateTestSetup();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
random.EffectChance(30, move, target, 0).Returns(true);
|
||||
|
||||
// Act
|
||||
@@ -168,7 +166,7 @@ public class BounceTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, _, _, random) = CreateTestSetup();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
random.EffectChance(30, move, target, 0).Returns(false);
|
||||
|
||||
// Act
|
||||
@@ -187,7 +185,7 @@ public class BounceTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, _, _, random) = CreateTestSetup();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
@@ -197,24 +195,6 @@ public class BounceTests
|
||||
await Assert.That(random.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "EffectChance")).IsTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: outside of battle (no battle data) the secondary effect does nothing and does not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_NoBattleData_DoesNotParalyzeTarget()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, user, _, _, _) = CreateTestSetup();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(target.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "SetStatus")).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "While in Sky-High status, the user is invulnerable to most moves".
|
||||
/// The <see cref="ChargeBounceEffect"/> added by the charge turn blocks incoming hits from moves that
|
||||
|
||||
Reference in New Issue
Block a user