Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -15,7 +15,7 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class GrowthTests
|
||||
{
|
||||
private static (Growth script, IExecutingMove move, IPokemon user, IBattle battle) CreateTestSetup(
|
||||
private static (Growth script, IExecutingMove move, IBattlePokemon user, IBattle battle) CreateTestSetup(
|
||||
StringKey? weather = null)
|
||||
{
|
||||
var script = new Growth();
|
||||
@@ -25,7 +25,7 @@ public class GrowthTests
|
||||
battle.WeatherName.Returns(weather);
|
||||
move.Battle.Returns(battle);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
|
||||
return (script, move, user, battle);
|
||||
@@ -36,7 +36,7 @@ public class GrowthTests
|
||||
/// null when that stat was not boosted. Received-call inspection is used instead of NSubstitute
|
||||
/// argument matchers because the trailing 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);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class GrowthTests
|
||||
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);
|
||||
@@ -71,7 +71,7 @@ public class GrowthTests
|
||||
var (script, move, user, _) = CreateTestSetup(ScriptUtils.ResolveName<HarshSunlight>());
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
var args = GetStatBoostArgs(user, stat);
|
||||
@@ -90,7 +90,7 @@ public class GrowthTests
|
||||
var (script, move, user, _) = CreateTestSetup(new StringKey("rain"));
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
var args = GetStatBoostArgs(user, Statistic.Attack);
|
||||
@@ -108,7 +108,7 @@ public class GrowthTests
|
||||
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.Defense)).IsNull();
|
||||
|
||||
Reference in New Issue
Block a user