using System.Runtime.CompilerServices;
using ClaudeDo.Ui.Services;

namespace ClaudeDo.Worker.Tests;

internal static class TestSetup
{
    // Runs once when this test assembly loads, before any test executes. UiVm/*Tests.cs construct
    // real TasksIslandViewModel instances, whose LoadForListAsync/ReorderAsync/ReconcileTickAsync
    // call OperationTiming.Shared.Record directly — without a redirect those writes land in the
    // live app's ~/.todo-app/logs/operation-timing.ndjson (see ClaudeDo.Ui.Tests' TestSetup for
    // the same trap on the Ui.Tests side).
    [ModuleInitializer]
    internal static void RedirectOperationTimingAwayFromRealAppData()
    {
        var path = Path.Combine(Path.GetTempPath(), "claudedo-worker-tests", $"operation-timing-{Environment.ProcessId}.ndjson");
        OperationTiming.Shared = new OperationTiming(path);
    }
}
