Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -21,9 +21,9 @@ public class BatonPassTests
|
||||
/// Creates a mocked Pokémon with a real volatile <see cref="ScriptSet"/> and a real
|
||||
/// <see cref="StatBoostStatisticSet"/>.
|
||||
/// </summary>
|
||||
private static IPokemon CreateMockPokemon(out IScriptSet volatileSet)
|
||||
private static IBattlePokemon CreateMockPokemon(out IScriptSet volatileSet)
|
||||
{
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.GetScripts().Returns(_ => new ScriptIterator(Array.Empty<IEnumerable<ScriptContainer>>()));
|
||||
var set = new ScriptSet(pokemon);
|
||||
pokemon.Volatile.Returns(set);
|
||||
@@ -36,8 +36,8 @@ public class BatonPassTests
|
||||
/// Creates a fully mocked test setup for Baton Pass tests. The Pokémon to switch in is stored in the
|
||||
/// move choice's <see cref="IMoveChoice.AdditionalData"/> under the <c>to_switch</c> key.
|
||||
/// </summary>
|
||||
private static (BatonPass script, IExecutingMove move, IPokemon user, IPokemon toSwitch, IBattleSide side,
|
||||
IScriptSet userVolatile, IScriptSet switchInVolatile) CreateTestSetup()
|
||||
private static (BatonPass script, IExecutingMove move, IBattlePokemon user, IBattlePokemon toSwitch, IBattleSide
|
||||
side, IScriptSet userVolatile, IScriptSet switchInVolatile) CreateTestSetup()
|
||||
{
|
||||
var script = new BatonPass();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
@@ -52,11 +52,9 @@ public class BatonPassTests
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.Sides.Returns(new[] { side });
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
battleData.SideIndex.Returns((byte)0);
|
||||
battleData.Position.Returns((byte)1);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
user.SideIndex.Returns((byte)0);
|
||||
user.Position.Returns((byte)1);
|
||||
|
||||
move.User.Returns(user);
|
||||
return (script, move, user, toSwitch, side, userVolatile, switchInVolatile);
|
||||
@@ -213,7 +211,7 @@ public class BatonPassTests
|
||||
script.OnSecondaryEffect(move, user, 0);
|
||||
|
||||
// Assert
|
||||
side.DidNotReceive().SwapPokemon(Arg.Any<byte>(), Arg.Any<IPokemon?>());
|
||||
side.DidNotReceive().SwapPokemon(Arg.Any<byte>(), Arg.Any<IBattlePokemon?>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -230,26 +228,6 @@ public class BatonPassTests
|
||||
script.OnSecondaryEffect(move, user, 0);
|
||||
|
||||
// Assert
|
||||
side.DidNotReceive().SwapPokemon(Arg.Any<byte>(), Arg.Any<IPokemon?>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: if the user has no <see cref="IPokemon.BattleData"/>, the script returns without
|
||||
/// switching and without clearing the user's volatile scripts.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_NoBattleData_DoesNotSwitch()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, user, _, side, userVolatile, _) = CreateTestSetup();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
userVolatile.Add(new AutotomizeEffect());
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, user, 0);
|
||||
|
||||
// Assert
|
||||
side.DidNotReceive().SwapPokemon(Arg.Any<byte>(), Arg.Any<IPokemon?>());
|
||||
await Assert.That(userVolatile.Get<AutotomizeEffect>()).IsNotNull();
|
||||
side.DidNotReceive().SwapPokemon(Arg.Any<byte>(), Arg.Any<IBattlePokemon?>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user