Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -31,12 +31,9 @@ public class MistTests
|
||||
IScriptSet sideScripts = new ScriptSet(side);
|
||||
side.VolatileScripts.Returns(sideScripts);
|
||||
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.BattleSide.Returns(side);
|
||||
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns(battleData);
|
||||
var user = Substitute.For<IBattlePokemon>();
|
||||
move.User.Returns(user);
|
||||
user.BattleSide.Returns(side);
|
||||
|
||||
return (script, move, side, sideScripts);
|
||||
}
|
||||
@@ -52,30 +49,12 @@ public class MistTests
|
||||
var (script, move, _, sideScripts) = CreateTestSetup();
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(sideScripts.Contains(ScriptUtils.ResolveName<MistEffect>())).IsTrue();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: without battle data on the user (outside of battle) the effect does nothing and does
|
||||
/// not throw.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task OnSecondaryEffect_UserHasNoBattleData_DoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, _, sideScripts) = CreateTestSetup();
|
||||
move.User.BattleData.Returns((IPokemonBattleData?)null);
|
||||
|
||||
// Act
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
|
||||
// Assert
|
||||
await Assert.That(sideScripts.Count).IsEqualTo(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bulbapedia: "While Mist is in effect, other Pokémon (including allies) cannot lower the stats of
|
||||
/// Pokémon protected by Mist using either moves or Abilities (e.g. Intimidate)." — a stat reduction
|
||||
@@ -87,7 +66,7 @@ public class MistTests
|
||||
{
|
||||
// Arrange
|
||||
var effect = new MistEffect();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var prevent = false;
|
||||
|
||||
// Act
|
||||
@@ -106,7 +85,7 @@ public class MistTests
|
||||
{
|
||||
// Arrange
|
||||
var effect = new MistEffect();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var prevent = false;
|
||||
|
||||
// Act
|
||||
@@ -124,7 +103,7 @@ public class MistTests
|
||||
{
|
||||
// Arrange
|
||||
var effect = new MistEffect();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var prevent = false;
|
||||
|
||||
// Act
|
||||
@@ -144,7 +123,7 @@ public class MistTests
|
||||
{
|
||||
// Arrange
|
||||
var effect = new MistEffect();
|
||||
var target = Substitute.For<IPokemon>();
|
||||
var target = Substitute.For<IBattlePokemon>();
|
||||
var prevent = false;
|
||||
|
||||
// Act
|
||||
@@ -163,7 +142,7 @@ public class MistTests
|
||||
{
|
||||
// Arrange
|
||||
var (script, move, side, sideScripts) = CreateTestSetup();
|
||||
script.OnSecondaryEffect(move, Substitute.For<IPokemon>(), 0);
|
||||
script.OnSecondaryEffect(move, Substitute.For<IBattlePokemon>(), 0);
|
||||
var effect = sideScripts.Get<MistEffect>();
|
||||
await Assert.That(effect).IsNotNull();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user