using Managing.Domain.Workflows;
using Xunit;
using static Managing.Common.Enums;

namespace Managing.Application.Tests;

public class WorkflowTests : BaseTests
{
    [Fact]
    public async Task Should_Create_Workflow_with_Feed_Ticker_Flow()
    {
        // Arrange
        var workflow = new Workflow
        {
            Name = "Bot trading",
            Usage = WorkflowUsage.Trading,
            Description = "Basic trading Workflow",
            Flows = new List<IFlow>()
        };

        // var rsiDivFlow = new RsiDiv()
        // {
        //     Parameters = "{\"Period\": 14,\"Timeframe\":1}",
        //     Children = new List<IFlow>(),
        // };

        // var tickerFlow = new FeedTicker(_exchangeService)
        // {
        //     Parameters = "{\"Exchange\": 3,\"Ticker\":9,\"Timeframe\":1}",
        //     Children = new List<IFlow>()
        //     {
        //         rsiDivFlow
        //     }
        // };

        // workflow.Flows.Add(tickerFlow);

        // Act
        await workflow.Execute();

        // Assert
        foreach (var f in workflow.Flows)
        {
            Assert.False(string.IsNullOrEmpty(f.Output));
        }

        Assert.NotNull(workflow);
        Assert.NotNull(workflow.Flows);
        Assert.Single(workflow.Flows);
        Assert.Equal("Feed Ticker", workflow.Name);
        Assert.Equal(WorkflowUsage.Trading, workflow.Usage);
        Assert.Equal("Basic trading Workflow", workflow.Description);
    }
}