Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -37,13 +37,13 @@ public class IceBurnTests
|
||||
/// Creates a fully mocked test setup for Ice Burn tests. The user gets a real <see cref="ScriptSet"/> as
|
||||
/// its volatile set, so the charge volatile added by the move can be inspected afterwards.
|
||||
/// </summary>
|
||||
private static (IceBurn script, IExecutingMove move, IPokemon user, ScriptSet userVolatile, IBattleRandom random,
|
||||
EventHook eventHook) CreateTestSetup()
|
||||
private static (IceBurn script, IExecutingMove move, IBattlePokemon user, ScriptSet userVolatile, IBattleRandom
|
||||
random, EventHook eventHook) CreateTestSetup()
|
||||
{
|
||||
var script = new IceBurn();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
move.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
user.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
|
||||
var userVolatile = new ScriptSet(user);
|
||||
user.Volatile.Returns(userVolatile);
|
||||
@@ -54,9 +54,7 @@ public class IceBurnTests
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.EventHook.Returns(eventHook);
|
||||
battle.Random.Returns(random);
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
return (script, move, user, userVolatile, random, eventHook);
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public class IceBurnTests
|
||||
/// Helper to check whether a Pokémon received any SetStatus call. (Checked via ReceivedCalls, as arg
|
||||
/// matchers cannot be used for <see cref="EventBatchId"/> parameters.)
|
||||
/// </summary>
|
||||
private static bool ReceivedSetStatus(IPokemon pokemon) =>
|
||||
private static bool ReceivedSetStatus(IBattlePokemon pokemon) =>
|
||||
pokemon.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "SetStatus");
|
||||
|
||||
/// <summary>
|
||||
@@ -177,7 +175,7 @@ public class IceBurnTests
|
||||
{
|
||||
// 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
|
||||
@@ -195,7 +193,7 @@ public class IceBurnTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, _, random, _) = CreateTestSetup();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
@@ -213,7 +211,7 @@ public class IceBurnTests
|
||||
{
|
||||
// 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
|
||||
@@ -223,28 +221,6 @@ public class IceBurnTests
|
||||
await Assert.That(ReceivedSetStatus(target)).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: if the user has no <see cref="IPokemon.BattleData"/>, the secondary effect does
|
||||
/// nothing.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_UserHasNoBattleData_DoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var script = new IceBurn();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
move.User.Returns(user);
|
||||
var target = Substitute.For<IPokemon>();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(ReceivedSetStatus(target)).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "A Power Herb item can bypass the charging phase entirely." The bypass flows through the
|
||||
/// <see cref="CustomTriggers.BypassChargeMove"/> custom trigger; a script that sets the bypass flag
|
||||
|
||||
Reference in New Issue
Block a user