Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -14,8 +14,8 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class MatBlockTests
|
||||
{
|
||||
private static (MatBlock script, IExecutingMove move, IPokemon target, IHitData hitData, IScriptSet sideVolatile)
|
||||
CreateTestSetup(uint switchInTurn, uint currentTurn)
|
||||
private static (MatBlock script, IExecutingMove move, IBattlePokemon target, IHitData hitData, IScriptSet
|
||||
sideVolatile) CreateTestSetup(uint switchInTurn, uint currentTurn)
|
||||
{
|
||||
var script = new MatBlock();
|
||||
|
||||
@@ -28,17 +28,14 @@ public class MatBlockTests
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.CurrentTurnNumber.Returns(currentTurn);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
battleData.BattleSide.Returns(side);
|
||||
battleData.SwitchInTurn.Returns(switchInTurn);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
user.SwitchInTurn.Returns(switchInTurn);
|
||||
user.BattleSide.Returns(side);
|
||||
user.Battle.Returns(battle);
|
||||
move.User.Returns(user);
|
||||
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var hitData = Substitute.For<IHitData>();
|
||||
move.GetHitData(target, 0).Returns(hitData);
|
||||
|
||||
@@ -135,7 +132,7 @@ public class MatBlockTests
|
||||
var block = false;
|
||||
|
||||
// Act
|
||||
effect.BlockIncomingHit(incomingMove, Substitute.For<IPokemon>(), 0, ref block);
|
||||
effect.BlockIncomingHit(incomingMove, Substitute.For<IBattlePokemon>(), 0, ref block);
|
||||
|
||||
// Assert
|
||||
await Assert.That(block).IsTrue();
|
||||
@@ -154,7 +151,7 @@ public class MatBlockTests
|
||||
var block = false;
|
||||
|
||||
// Act
|
||||
effect.BlockIncomingHit(incomingMove, Substitute.For<IPokemon>(), 0, ref block);
|
||||
effect.BlockIncomingHit(incomingMove, Substitute.For<IBattlePokemon>(), 0, ref block);
|
||||
|
||||
// Assert
|
||||
await Assert.That(block).IsFalse();
|
||||
@@ -180,23 +177,4 @@ public class MatBlockTests
|
||||
// Assert
|
||||
await Assert.That(sideVolatile.Contains(ScriptUtils.ResolveName<MatBlockEffect>())).IsFalse();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: outside of battle (no battle data) no protection can be raised and nothing
|
||||
/// happens.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_NullBattleData_DoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, target, hitData, sideVolatile) = CreateTestSetup(1, 1);
|
||||
move.User.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert - no effect is added and the hit is not failed
|
||||
await Assert.That(sideVolatile.Contains(ScriptUtils.ResolveName<MatBlockEffect>())).IsFalse();
|
||||
await Assert.That(hitData.ReceivedCalls().Any(c => c.GetMethodInfo().Name == "Fail")).IsFalse();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user