Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -17,8 +17,8 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class AutotomizeTests
|
||||
{
|
||||
private static (Autotomize script, IExecutingMove move, IPokemon user, IScriptSet userVolatile, EventHook eventHook)
|
||||
CreateTestSetup(float weightInKg, bool speedRaiseSucceeds, AutotomizeEffect? existingEffect = null)
|
||||
private static (Autotomize script, IExecutingMove move, IBattlePokemon user, IScriptSet userVolatile, EventHook
|
||||
eventHook) CreateTestSetup(float weightInKg, bool speedRaiseSucceeds, AutotomizeEffect? existingEffect = null)
|
||||
{
|
||||
var script = new Autotomize();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
@@ -26,15 +26,13 @@ public class AutotomizeTests
|
||||
var eventHook = new EventHook();
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.EventHook.Returns(eventHook);
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
|
||||
var userVolatile = Substitute.For<IScriptSet>();
|
||||
userVolatile.Get<AutotomizeEffect>().Returns(existingEffect);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
user.Volatile.Returns(userVolatile);
|
||||
user.Battle.Returns(battle);
|
||||
user.WeightInKg.Returns(weightInKg);
|
||||
user.ChangeStatBoost(Arg.Any<Statistic>(), Arg.Any<sbyte>(), Arg.Any<bool>(), Arg.Any<bool>())
|
||||
.Returns(speedRaiseSucceeds);
|
||||
@@ -56,7 +54,7 @@ public class AutotomizeTests
|
||||
var (script, move, user, _, _) = CreateTestSetup(100f, true);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
user.Received(1).ChangeStatBoost(Statistic.Speed, 2, true, false);
|
||||
@@ -79,7 +77,7 @@ public class AutotomizeTests
|
||||
};
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(ReceivedStackOrAdd(userVolatile)).IsTrue();
|
||||
@@ -100,7 +98,7 @@ public class AutotomizeTests
|
||||
eventHook.Handler += (_, _) => eventFired = true;
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(ReceivedStackOrAdd(userVolatile)).IsFalse();
|
||||
@@ -119,7 +117,7 @@ public class AutotomizeTests
|
||||
var (script, move, _, userVolatile, _) = CreateTestSetup(50f, true);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(ReceivedStackOrAdd(userVolatile)).IsTrue();
|
||||
@@ -140,7 +138,7 @@ public class AutotomizeTests
|
||||
var (script, move, _, userVolatile, _) = CreateTestSetup(50f, true, existingEffect);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert - the weight should still be reduced (to the minimum)
|
||||
await Assert.That(ReceivedStackOrAdd(userVolatile)).IsTrue();
|
||||
@@ -160,7 +158,7 @@ public class AutotomizeTests
|
||||
eventHook.Handler += (_, _) => eventFired = true;
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
user.Received(1).ChangeStatBoost(Statistic.Speed, 2, true, false);
|
||||
|
||||
Reference in New Issue
Block a user