using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Static;

namespace PkmnLib.Plugin.Gen7.Tests.Scripts.Moves;

public class AcrobaticsTests
{
    [Test]
    public async Task ChangeBasePower_UserNotHoldingItem_BasePowerDoubles()
    {
        // Arrange
        var move = Substitute.For<IExecutingMove>();
        var target = Substitute.For<IPokemon>();
        ushort basePower = 10;
        var user = Substitute.For<IPokemon>();
        user.HeldItem.Returns((IItem?)null);
        move.User.Returns(user);
        var acrobatics = new Acrobatics();

        // Act
        acrobatics.ChangeBasePower(move, target, 0, ref basePower);

        // Assert
        await Assert.That(basePower).IsEqualTo((ushort)20);
    }

    [Test]
    public async Task ChangeBasePower_UserHoldingItem_BasePowerUnchanged()
    {
        // Arrange
        var move = Substitute.For<IExecutingMove>();
        var target = Substitute.For<IPokemon>();
        ushort basePower = 10;
        var user = Substitute.For<IPokemon>();
        user.HeldItem.Returns(Substitute.For<IItem>());
        move.User.Returns(user);
        var acrobatics = new Acrobatics();

        // Act
        acrobatics.ChangeBasePower(move, target, 0, ref basePower);

        // Assert
        await Assert.That(basePower).IsEqualTo((ushort)10);
    }

    [Test]
    public async Task ChangeBasePower_UserNotHoldingItem_NoOverflow()
    {
        // Arrange
        var move = Substitute.For<IExecutingMove>();
        var target = Substitute.For<IPokemon>();
        ushort basePower = ushort.MaxValue - 100;
        var user = Substitute.For<IPokemon>();
        move.User.Returns(user);
        user.HeldItem.Returns((IItem?)null);
        var acrobatics = new Acrobatics();

        // Act
        acrobatics.ChangeBasePower(move, target, 0, ref basePower);

        // Assert
        await Assert.That(basePower).IsEqualTo(ushort.MaxValue);
    }
}