Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -15,21 +15,19 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
public class BrickBreakTests
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a mocked Pokémon whose <see cref="IPokemonBattleData.BattleSide"/> is the given side.
|
||||
/// Creates a mocked Pokémon whose <see cref="IBattlePokemon.BattleSide"/> is the given side.
|
||||
/// </summary>
|
||||
private static IPokemon CreatePokemonOnSide(IBattleSide side)
|
||||
private static IBattlePokemon CreatePokemonOnSide(IBattleSide side)
|
||||
{
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.BattleSide.Returns(side);
|
||||
pokemon.BattleData.Returns(battleData);
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
pokemon.BattleSide.Returns(side);
|
||||
return pokemon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a fully mocked test setup where the user targets a Pokémon on the opposing side.
|
||||
/// </summary>
|
||||
private static (BrickBreak script, IExecutingMove move, IPokemon user, IScriptSet userSideScripts, IScriptSet
|
||||
private static (BrickBreak script, IExecutingMove move, IBattlePokemon user, IScriptSet userSideScripts, IScriptSet
|
||||
targetSideScripts) CreateTestSetup()
|
||||
{
|
||||
var script = new BrickBreak();
|
||||
@@ -45,7 +43,7 @@ public class BrickBreakTests
|
||||
var user = CreatePokemonOnSide(userSide);
|
||||
move.User.Returns(user);
|
||||
var target = CreatePokemonOnSide(targetSide);
|
||||
move.Targets.Returns(new IPokemon?[] { target });
|
||||
move.Targets.Returns(new IBattlePokemon?[] { target });
|
||||
|
||||
return (script, move, user, userSideScripts, targetSideScripts);
|
||||
}
|
||||
@@ -115,8 +113,8 @@ public class BrickBreakTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, user, userSideScripts, _) = CreateTestSetup();
|
||||
var ally = CreatePokemonOnSide(user.BattleData!.BattleSide);
|
||||
move.Targets.Returns(new IPokemon?[] { ally });
|
||||
var ally = CreatePokemonOnSide(user.BattleSide);
|
||||
move.Targets.Returns(new IBattlePokemon?[] { ally });
|
||||
|
||||
// Act
|
||||
script.OnBeforeMove(move);
|
||||
@@ -146,7 +144,7 @@ public class BrickBreakTests
|
||||
var user = CreatePokemonOnSide(userSide);
|
||||
move.User.Returns(user);
|
||||
var target = CreatePokemonOnSide(targetSide);
|
||||
move.Targets.Returns(new IPokemon?[] { target });
|
||||
move.Targets.Returns(new IBattlePokemon?[] { target });
|
||||
|
||||
// Act
|
||||
script.OnBeforeMove(move);
|
||||
@@ -165,10 +163,9 @@ public class BrickBreakTests
|
||||
// Arrange
|
||||
var script = new BrickBreak();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
move.Targets.Returns(Array.Empty<IPokemon?>());
|
||||
move.Targets.Returns(Array.Empty<IBattlePokemon?>());
|
||||
|
||||
// Act & Assert
|
||||
await Assert.That(() => script.OnBeforeMove(move)).ThrowsNothing();
|
||||
|
||||
Reference in New Issue
Block a user