Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper

This commit is contained in:
2026-08-28 15:20:26 +02:00
parent 942be8eaeb
commit 8a2733a0a9
859 changed files with 4408 additions and 5331 deletions

View File

@@ -13,13 +13,13 @@ namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
public class BelchTests
{
/// <summary>
/// Creates a fully mocked test setup where the user's <see cref="IPokemonBattleData.ConsumedItems"/>
/// Creates a fully mocked test setup where the user's <see cref="IBattlePokemon.ConsumedItems"/>
/// contains one item per given <see cref="ItemCategory"/>.
/// </summary>
private static (Belch script, IMoveChoice choice) CreateTestSetup(params ItemCategory[] consumedItemCategories)
{
var script = new Belch();
var user = Substitute.For<IPokemon>();
var user = Substitute.For<IBattlePokemon>();
var items = consumedItemCategories.Select(category =>
{
@@ -27,9 +27,7 @@ public class BelchTests
item.Category.Returns(category);
return item;
}).ToArray();
var battleData = Substitute.For<IPokemonBattleData>();
battleData.ConsumedItems.Returns(items);
user.BattleData.Returns(battleData);
user.ConsumedItems.Returns(items);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
@@ -108,26 +106,4 @@ public class BelchTests
// Assert
await Assert.That(prevent).IsFalse();
}
/// <summary>
/// Technical test: outside of battle (no <see cref="IPokemon.BattleData"/>) the script does not prevent
/// selection.
/// </summary>
[Test]
public async Task PreventMoveSelection_NoBattleData_SelectionAllowed()
{
// Arrange
var script = new Belch();
var user = Substitute.For<IPokemon>();
user.BattleData.Returns((IPokemonBattleData?)null);
var choice = Substitute.For<IMoveChoice>();
choice.User.Returns(user);
var prevent = false;
// Act
script.PreventMoveSelection(choice, ref prevent);
// Assert
await Assert.That(prevent).IsFalse();
}
}