using RolemasterDb.App.Domain;
using RolemasterDb.App.Features;

namespace RolemasterDb.ImportTool.Tests;

public sealed class CriticalCellComparisonEvaluatorTests
{
    [Fact]
    public void Effects_do_not_differ_when_only_source_metadata_changes()
    {
        var currentEffects = new[]
        {
            new CriticalEffectLookupResponse(
                CriticalEffectCodes.MustParryRounds,
                "foe",
                null,
                null,
                1,
                null,
                null,
                null,
                false,
                "symbol",
                "π")
        };
        var generatedEffects = new[]
        {
            new CriticalEffectLookupResponse(
                CriticalEffectCodes.MustParryRounds,
                "foe",
                null,
                null,
                1,
                null,
                null,
                null,
                false,
                "quick",
                "1mp")
        };

        Assert.False(CriticalCellComparisonEvaluator.EffectsDiffer(currentEffects, generatedEffects));
    }

    [Fact]
    public void Difference_count_detects_actual_visible_effect_changes()
    {
        var currentEffects = new[]
        {
            new CriticalEffectLookupResponse(
                CriticalEffectCodes.DirectHits,
                "foe",
                5,
                null,
                null,
                null,
                null,
                null,
                false,
                "import",
                "+5")
        };
        var generatedState = new CriticalCellComparisonState(
            "Arcane force staggers the foe.",
            [
                new CriticalEffectLookupResponse(
                    CriticalEffectCodes.DirectHits,
                    "foe",
                    10,
                    null,
                    null,
                    null,
                    null,
                    null,
                    false,
                    "quick",
                    "+10")
            ],
            [],
            [],
            []);

        var differenceCount = CriticalCellComparisonEvaluator.GetDifferenceCount(
            "Arcane force staggers the foe.",
            currentEffects,
            [],
            generatedState);

        Assert.Equal(1, differenceCount);
    }
}
