Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -22,12 +22,12 @@ public class ForesightTests
|
||||
/// Creates a fully mocked test setup for Foresight tests. The target is in battle, with a mocked
|
||||
/// battle library chain and the given evasion stat stage.
|
||||
/// </summary>
|
||||
private static (Foresight script, IExecutingMove move, IPokemon target, IScriptSet volatileSet, IHitData hitData)
|
||||
CreateTestSetup(sbyte evasionStage = 0)
|
||||
private static (Foresight script, IExecutingMove move, IBattlePokemon target, IScriptSet volatileSet, IHitData
|
||||
hitData) CreateTestSetup(sbyte evasionStage = 0)
|
||||
{
|
||||
var script = new Foresight();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var hitData = Substitute.For<IHitData>();
|
||||
move.GetHitData(target, 0).Returns(hitData);
|
||||
|
||||
@@ -38,9 +38,7 @@ public class ForesightTests
|
||||
library.StaticLibrary.Returns(staticLibrary);
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.Library.Returns(library);
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
target.BattleData.Returns(battleData);
|
||||
target.Battle.Returns(battle);
|
||||
|
||||
var volatileSet = Substitute.For<IScriptSet>();
|
||||
target.Volatile.Returns(volatileSet);
|
||||
@@ -54,9 +52,9 @@ public class ForesightTests
|
||||
|
||||
/// <summary>
|
||||
/// Helper to extract all stat boost changes requested on the target through
|
||||
/// <see cref="IPokemon.ChangeStatBoost"/>.
|
||||
/// <see cref="IBattlePokemon.ChangeStatBoost"/>.
|
||||
/// </summary>
|
||||
private static IReadOnlyList<(Statistic stat, sbyte amount)> GetStatBoostChanges(IPokemon target) =>
|
||||
private static IReadOnlyList<(Statistic stat, sbyte amount)> GetStatBoostChanges(IBattlePokemon target) =>
|
||||
target.ReceivedCalls().Where(c => c.GetMethodInfo().Name == "ChangeStatBoost")
|
||||
.Select(c => ((Statistic)c.GetArguments()[0]!, (sbyte)c.GetArguments()[1]!)).ToList();
|
||||
|
||||
@@ -143,25 +141,6 @@ public class ForesightTests
|
||||
await Assert.That(changes.Any(c => c.amount != 0)).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the target has no <see cref="IPokemon.BattleData"/>, the script cannot resolve the type library,
|
||||
/// so nothing may happen: no volatile script is added and no stat stage is changed.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_NullBattleData_NoEffect()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, target, volatileSet, _) = CreateTestSetup(2);
|
||||
target.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(volatileSet.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "Add")).IsFalse();
|
||||
await Assert.That(target.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "ChangeStatBoost")).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia (Generations V to VII): "Foresight will once again fail if used against a Pokémon already
|
||||
/// under its effect."
|
||||
|
||||
Reference in New Issue
Block a user