using Sdt.Config;
using Sdt.Core;
using Xunit;

namespace DevTool.Tests;

public sealed class RequirementResolverTests
{
    private readonly RequirementResolver _resolver = new();

    [Fact]
    public void TauriBuildAction_RequiresNodeNpmCargo_NotGlobalTauri()
    {
        var step = new WorkflowStep
        {
            Id = "tauri",
            Label = "tauri",
            Action = "tauri-build",
        };

        var tools = _resolver.Resolve(step).Select(r => r.Tool).ToHashSet(StringComparer.OrdinalIgnoreCase);
        Assert.Contains("node", tools);
        Assert.Contains("npm", tools);
        Assert.Contains("cargo", tools);
        Assert.DoesNotContain("tauri", tools);
    }

    [Fact]
    public void LegacyPwshTarget_InferenceMatchesExpected()
    {
        var target = new BuildTarget
        {
            Id = "web",
            Label = "Web",
            Command = "pwsh",
            Args = ["-NoProfile", "-File", "scripts/publish-app.ps1", "-Target", "web"],
        };

        var tools = _resolver.Resolve(target).Select(r => r.Tool).ToHashSet(StringComparer.OrdinalIgnoreCase);
        Assert.Contains("python", tools);
        Assert.Contains("node", tools);
        Assert.Contains("npm", tools);
    }
}
