// Copyright (c) Microsoft. All rights reserved.

using System.IO;
using System.Threading.Tasks;
using static Microsoft.Agents.AI.Workflows.Sample.Step1EntryPoint;

namespace Microsoft.Agents.AI.Workflows.Sample;

internal static class Step1aEntryPoint
{
    // TODO: Maybe env.CreateRunAsync?
    public static async ValueTask RunAsync(TextWriter writer, IWorkflowExecutionEnvironment environment)
    {
        Run run = await environment.RunAsync(WorkflowInstance, "Hello, World!").ConfigureAwait(false);

        Assert.Equal(RunStatus.Idle, await run.GetStatusAsync());

        foreach (WorkflowEvent evt in run.NewEvents)
        {
            if (evt is ExecutorCompletedEvent executorCompleted)
            {
                writer.WriteLine($"{executorCompleted.ExecutorId}: {executorCompleted.Data}");
            }
        }
    }
}
