Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -15,9 +15,9 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
||||
/// </summary>
|
||||
public class AssistTests
|
||||
{
|
||||
private static IPokemon CreatePokemonWithMoves(params string[] moveNames)
|
||||
private static IBattlePokemon CreatePokemonWithMoves(params string[] moveNames)
|
||||
{
|
||||
var pokemon = Substitute.For<IPokemon>();
|
||||
var pokemon = Substitute.For<IBattlePokemon>();
|
||||
var moves = moveNames.Select(name =>
|
||||
{
|
||||
var learned = Substitute.For<ILearnedMove>();
|
||||
@@ -30,27 +30,23 @@ public class AssistTests
|
||||
return pokemon;
|
||||
}
|
||||
|
||||
private static (Assist script, IMoveChoice choice, IPokemon user, IBattleRandom random) CreateTestSetup(
|
||||
params IPokemon?[] otherPartyMembers)
|
||||
private static (Assist script, IMoveChoice choice, IBattlePokemon user, IBattleRandom random) CreateTestSetup(
|
||||
params IBattlePokemon?[] otherPartyMembers)
|
||||
{
|
||||
var script = new Assist();
|
||||
var user = CreatePokemonWithMoves("tackle");
|
||||
|
||||
var members = new List<IPokemon?> { user };
|
||||
var members = new List<IBattlePokemon?> { user };
|
||||
members.AddRange(otherPartyMembers);
|
||||
|
||||
var party = Substitute.For<IPokemonParty>();
|
||||
party.GetEnumerator().Returns(_ => members.GetEnumerator());
|
||||
var battleParty = Substitute.For<IBattleParty>();
|
||||
battleParty.Party.Returns(party);
|
||||
battleParty.BattlePokemon.Returns(members);
|
||||
|
||||
var random = Substitute.For<IBattleRandom>();
|
||||
var battle = Substitute.For<IBattle>();
|
||||
battle.Parties.Returns(new[] { battleParty });
|
||||
battle.Random.Returns(random);
|
||||
var battleData = Substitute.For<IPokemonBattleData>();
|
||||
battleData.Battle.Returns(battle);
|
||||
user.BattleData.Returns(battleData);
|
||||
user.Battle.Returns(battle);
|
||||
|
||||
var choice = Substitute.For<IMoveChoice>();
|
||||
choice.User.Returns(user);
|
||||
@@ -180,26 +176,4 @@ public class AssistTests
|
||||
await Assert.That(moveName).IsEqualTo(new StringKey("growl"));
|
||||
choice.DidNotReceive().Fail();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Technical test: outside of battle (no battle data) the script returns without failing the choice.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task ChangeMove_NoBattleData_DoesNothing()
|
||||
{
|
||||
// Arrange
|
||||
var script = new Assist();
|
||||
var user = Substitute.For<IPokemon>();
|
||||
user.BattleData.Returns((IPokemonBattleData?)null);
|
||||
var choice = Substitute.For<IMoveChoice>();
|
||||
choice.User.Returns(user);
|
||||
StringKey moveName = "assist";
|
||||
|
||||
// Act
|
||||
script.ChangeMove(choice, ref moveName);
|
||||
|
||||
// Assert
|
||||
choice.DidNotReceive().Fail();
|
||||
await Assert.That(moveName).IsEqualTo(new StringKey("assist"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user