Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -13,7 +13,7 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class CamouflageTests
|
||||
{
|
||||
private static (Camouflage script, IExecutingMove move, IPokemon user, IBattle battle) CreateTestSetup(
|
||||
private static (Camouflage script, IExecutingMove move, IBattlePokemon user, IBattle battle) CreateTestSetup(
|
||||
string? terrainName, string environmentName)
|
||||
{
|
||||
var script = new Camouflage();
|
||||
@@ -24,7 +24,7 @@ public class CamouflageTests
|
||||
battle.TerrainName.Returns(terrainName == null ? null : new StringKey?(new StringKey(terrainName)));
|
||||
battle.EnvironmentName.Returns(new StringKey(environmentName));
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
move.User.Returns(user);
|
||||
move.Battle.Returns(battle);
|
||||
@@ -34,9 +34,9 @@ public class CamouflageTests
|
||||
|
||||
/// <summary>
|
||||
/// Helper that returns the single type the user was changed to, or null when
|
||||
/// <see cref="IPokemon.SetTypes"/> was never called.
|
||||
/// <see cref="IBattlePokemon.SetTypes"/> was never called.
|
||||
/// </summary>
|
||||
private static TypeIdentifier? GetSetType(IPokemon user)
|
||||
private static TypeIdentifier? GetSetType(IBattlePokemon user)
|
||||
{
|
||||
var call = user.ReceivedCalls().FirstOrDefault(c => c.GetMethodInfo().Name == "SetTypes");
|
||||
return call != null ? ((IReadOnlyList<TypeIdentifier>)call.GetArguments()[0]!).Single() : null;
|
||||
@@ -56,7 +56,7 @@ public class CamouflageTests
|
||||
battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(expectedType, out var expected);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(GetSetType(user)!.Value).IsEqualTo(expected);
|
||||
@@ -75,7 +75,7 @@ public class CamouflageTests
|
||||
battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(expectedType, out var expected);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(GetSetType(user)!.Value).IsEqualTo(expected);
|
||||
@@ -92,7 +92,7 @@ public class CamouflageTests
|
||||
battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("normal", out var expected);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(GetSetType(user)!.Value).IsEqualTo(expected);
|
||||
@@ -107,7 +107,7 @@ public class CamouflageTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, _) = CreateTestSetup(null, "field");
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
Reference in New Issue
Block a user