82 lines
3.2 KiB
C#
82 lines
3.2 KiB
C#
using PkmnLib.Dynamic.Models;
|
|
using PkmnLib.Plugin.Gen7.Scripts.Moves;
|
|
|
|
namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;
|
|
|
|
/// <summary>
|
|
/// Tests for the <see cref="FalseSwipe"/> move script.
|
|
/// Gen VII Bulbapedia behavior: "False Swipe inflicts damage, but will leave the target with 1 HP if it would
|
|
/// otherwise cause it to faint. If the target has 1 HP remaining, False Swipe will hit and leave the target
|
|
/// at 1 HP."
|
|
/// </summary>
|
|
public class FalseSwipeTests
|
|
{
|
|
/// <summary>
|
|
/// Creates a fully mocked test setup where the target has the given current health.
|
|
/// </summary>
|
|
private static (FalseSwipe script, IExecutingMove move, IPokemon target) CreateTestSetup(uint currentHealth)
|
|
{
|
|
var script = new FalseSwipe();
|
|
var move = Substitute.For<IExecutingMove>();
|
|
var target = Substitute.For<IPokemon>();
|
|
target.CurrentHealth.Returns(currentHealth);
|
|
return (script, move, target);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "False Swipe inflicts damage, but will leave the target with 1 HP if it would otherwise
|
|
/// cause it to faint." — damage exactly equal to the target's remaining HP is reduced to leave 1 HP.
|
|
/// The (1, 1, 0) row verifies "If the target has 1 HP remaining, False Swipe will hit and leave the
|
|
/// target at 1 HP."
|
|
/// </summary>
|
|
[Test, Arguments(50u, 50u, 49u), Arguments(100u, 100u, 99u), Arguments(1u, 1u, 0u)]
|
|
public async Task ChangeMoveDamage_DamageExactlyLethal_LeavesTargetWithOneHp(uint currentHealth, uint damage,
|
|
uint expectedDamage)
|
|
{
|
|
// Arrange
|
|
var (script, move, target) = CreateTestSetup(currentHealth);
|
|
|
|
// Act
|
|
script.ChangeMoveDamage(move, target, 0, ref damage);
|
|
|
|
// Assert
|
|
await Assert.That(damage).IsEqualTo(expectedDamage);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "False Swipe inflicts damage, but will leave the target with 1 HP if it would otherwise
|
|
/// cause it to faint." — damage exceeding the target's remaining HP is also capped so the target is left
|
|
/// at 1 HP.
|
|
/// </summary>
|
|
[Test, Arguments(50u, 100u, 49u), Arguments(1u, 5u, 0u), Arguments(30u, 4000u, 29u)]
|
|
public async Task ChangeMoveDamage_DamageExceedsCurrentHealth_LeavesTargetWithOneHp(uint currentHealth, uint damage,
|
|
uint expectedDamage)
|
|
{
|
|
// Arrange
|
|
var (script, move, target) = CreateTestSetup(currentHealth);
|
|
|
|
// Act
|
|
script.ChangeMoveDamage(move, target, 0, ref damage);
|
|
|
|
// Assert
|
|
await Assert.That(damage).IsEqualTo(expectedDamage);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Bulbapedia: "False Swipe inflicts damage" — when the damage would not cause the target to faint, it
|
|
/// is dealt in full.
|
|
/// </summary>
|
|
[Test, Arguments(100u, 50u), Arguments(100u, 99u), Arguments(2u, 1u)]
|
|
public async Task ChangeMoveDamage_DamageNotLethal_DamageUnchanged(uint currentHealth, uint damage)
|
|
{
|
|
// Arrange
|
|
var (script, move, target) = CreateTestSetup(currentHealth);
|
|
var originalDamage = damage;
|
|
|
|
// Act
|
|
script.ChangeMoveDamage(move, target, 0, ref damage);
|
|
|
|
// Assert
|
|
await Assert.That(damage).IsEqualTo(originalDamage);
|
|
}
|
|
} |