Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -19,7 +19,7 @@ public class DefogTests
|
||||
/// <summary>
|
||||
/// Creates a fully mocked test setup where the target is on side 1 and the user on side 0.
|
||||
/// </summary>
|
||||
private static (Defog script, IExecutingMove move, IPokemon target, IScriptSet targetSideScripts, IScriptSet
|
||||
private static (Defog script, IExecutingMove move, IBattlePokemon target, IScriptSet targetSideScripts, IScriptSet
|
||||
userSideScripts) CreateTestSetup()
|
||||
{
|
||||
var script = new Defog();
|
||||
@@ -35,18 +35,14 @@ public class DefogTests
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.Sides.Returns(new[] { userSide, targetSide });
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var userBattleData = Substitute.For<IPokemonBattleData>();
|
||||
userBattleData.Battle.Returns(battle);
|
||||
userBattleData.SideIndex.Returns((byte)0);
|
||||
user.BattleData.Returns(userBattleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
user.Battle.Returns(battle);
|
||||
user.SideIndex.Returns((byte)0);
|
||||
move.User.Returns(user);
|
||||
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var targetBattleData = Substitute.For<IPokemonBattleData>();
|
||||
targetBattleData.Battle.Returns(battle);
|
||||
targetBattleData.SideIndex.Returns((byte)1);
|
||||
target.BattleData.Returns(targetBattleData);
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
target.Battle.Returns(battle);
|
||||
target.SideIndex.Returns((byte)1);
|
||||
|
||||
return (script, move, target, targetSideScripts, userSideScripts);
|
||||
}
|
||||
@@ -144,21 +140,4 @@ public class DefogTests
|
||||
c.GetMethodInfo().Name == "ChangeStatBoost" && (Statistic)c.GetArguments()[0]! == Statistic.Evasion &&
|
||||
(sbyte)c.GetArguments()[1]! == -1)).IsTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data (outside of battle) the secondary effect does nothing and does
|
||||
/// not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_TargetHasNoBattleData_DoesNotThrow()
|
||||
{
|
||||
// Arrange
|
||||
var script = new Defog();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
target.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act & Assert
|
||||
await Assert.That(() => script.OnSecondaryEffect(move, target, 0)).ThrowsNothing();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user