using MBN_STOCK_WEBVIEW.LegacyBridge;

namespace MBN_STOCK_WEBVIEW.LegacyBridge.Tests;

public sealed class LegacySectionBatchBridgeTests
{
    [Theory]
    [InlineData("activate-industry-section", typeof(LegacyActivateIndustrySectionIntent))]
    [InlineData("activate-comparison-section", typeof(LegacyActivateComparisonSectionIntent))]
    public void SectionBatchIntentAcceptsOnlyOneBoundedOpaqueIndex(
        string type,
        Type expectedType)
    {
        Assert.True(LegacyBridgeProtocol.TryParseIntent(
            $"{{\"type\":\"{type}\",\"payload\":{{\"sectionIndex\":1}}}}",
            out var intent,
            out _));
        Assert.IsType(expectedType, intent);

        Assert.False(LegacyBridgeProtocol.TryParseIntent(
            $"{{\"type\":\"{type}\",\"payload\":{{\"sectionIndex\":64}}}}",
            out _,
            out _));
        Assert.False(LegacyBridgeProtocol.TryParseIntent(
            $"{{\"type\":\"{type}\",\"payload\":{{\"sectionIndex\":1,\"actions\":[]}}}}",
            out _,
            out _));
    }
}
