using ClaudeDo.Worker.Runner;
using Xunit;

namespace ClaudeDo.Worker.Tests.Runner;

public class MaxTurnsResolutionTests
{
    [Fact]
    public void Task_override_wins()
        => Assert.Equal(5, TaskRunner.ResolveMaxTurns(taskTurns: 5, listTurns: 20, globalDefault: 100, ceiling: 200));

    [Fact]
    public void List_override_used_when_no_task_override()
        => Assert.Equal(20, TaskRunner.ResolveMaxTurns(taskTurns: null, listTurns: 20, globalDefault: 100, ceiling: 200));

    [Fact]
    public void Falls_back_to_global_default()
        => Assert.Equal(100, TaskRunner.ResolveMaxTurns(taskTurns: null, listTurns: null, globalDefault: 100, ceiling: 200));

    [Fact]
    public void Below_ceiling_is_unchanged()
        => Assert.Equal(60, TaskRunner.ResolveMaxTurns(taskTurns: 60, listTurns: null, globalDefault: 40, ceiling: 80));

    [Fact]
    public void Above_ceiling_is_clamped()
        => Assert.Equal(80, TaskRunner.ResolveMaxTurns(taskTurns: 200, listTurns: null, globalDefault: 40, ceiling: 80));
}
