Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -15,11 +15,11 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class GeomancyTests
|
||||
{
|
||||
private static (Geomancy script, IExecutingMove move, IPokemon user, ScriptSet userVolatile) CreateTestSetup()
|
||||
private static (Geomancy script, IExecutingMove move, IBattlePokemon user, ScriptSet userVolatile) CreateTestSetup()
|
||||
{
|
||||
var script = new Geomancy();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
// Use a real script set so the charge volatile added by Geomancy can be inspected afterwards.
|
||||
var userVolatile = new ScriptSet(user);
|
||||
user.Volatile.Returns(userVolatile);
|
||||
@@ -31,9 +31,7 @@ public class GeomancyTests
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.EventHook.Returns(new EventHook());
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
return (script, move, user, userVolatile);
|
||||
}
|
||||
@@ -44,7 +42,7 @@ public class GeomancyTests
|
||||
/// argument matchers because the trailing <see cref="EventBatchId"/> parameter cannot be bound by
|
||||
/// <c>Arg.Any</c>.
|
||||
/// </summary>
|
||||
private static object?[]? GetStatBoostArgs(IPokemon pokemon, Statistic stat) =>
|
||||
private static object?[]? GetStatBoostArgs(IBattlePokemon pokemon, Statistic stat) =>
|
||||
pokemon.ReceivedCalls().Where(c => c.GetMethodInfo().Name == "ChangeStatBoost").Select(c => c.GetArguments())
|
||||
.FirstOrDefault(args => (Statistic)args[0]! == stat);
|
||||
|
||||
@@ -114,7 +112,7 @@ public class GeomancyTests
|
||||
var (script, move, user, _) = CreateTestSetup();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
var args = GetStatBoostArgs(user, stat);
|
||||
@@ -135,7 +133,7 @@ public class GeomancyTests
|
||||
var (script, move, user, _) = CreateTestSetup();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(GetStatBoostArgs(user, Statistic.Attack)).IsNull();
|
||||
|
||||
Reference in New Issue
Block a user