Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -18,23 +18,21 @@ public class MagicRoomTests
|
||||
/// Creates a fully mocked test setup for Magic Room tests. The battle gets a real
|
||||
/// <see cref="ScriptSet"/> as its volatile set, so the applied effect can be inspected.
|
||||
/// </summary>
|
||||
private static (MagicRoom script, IExecutingMove move, IPokemon target, IBattle battle, IScriptSet battleVolatile)
|
||||
CreateTestSetup()
|
||||
private static (MagicRoom script, IExecutingMove move, IBattlePokemon target, IBattle battle, IScriptSet
|
||||
battleVolatile) CreateTestSetup()
|
||||
{
|
||||
var script = new MagicRoom();
|
||||
var move = Substitute.For<IExecutingMove>();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.GetScripts().Returns(_ => new ScriptIterator(new List<IEnumerable<ScriptContainer>>()));
|
||||
var battleVolatile = new ScriptSet(battle);
|
||||
battle.Volatile.Returns(battleVolatile);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
return (script, move, target, battle, battleVolatile);
|
||||
}
|
||||
@@ -57,24 +55,6 @@ public class MagicRoomTests
|
||||
await Assert.That(battleVolatile.Get<MagicRoomEffect>()).IsNotNull();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: Magic Room affects "the Pokémon on the field"; a user without battle data has no field to
|
||||
/// affect, so no effect is applied and no exception is thrown.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_UserHasNoBattleData_NoEffectAdded()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, target, _, battleVolatile) = CreateTestSetup();
|
||||
move.User.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, target, 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(battleVolatile.Count).IsEqualTo(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "If Magic Room is used while it is already in effect, it will end immediately."
|
||||
/// Using the move a second time must remove the active effect from the battle instead of leaving it in
|
||||
@@ -105,7 +85,7 @@ public class MagicRoomTests
|
||||
{
|
||||
// Arrange
|
||||
var effect = new MagicRoomEffect();
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
var item = Substitute.For<IItem>();
|
||||
var prevented = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user