using System.Reflection;
using ScadaLink.Communication.Actors;

namespace ScadaLink.Communication.Tests.Grpc;

/// <summary>
/// Regression tests ensuring that the old ClusterClient-based debug streaming
/// path is not reintroduced. Debug streaming now flows through gRPC.
///
/// Note: The DebugStreamEvent type-does-not-exist check lives in
/// ScadaLink.Commons.Tests/ArchitecturalConstraintTests.cs and is not
/// duplicated here.
/// </summary>
public class NoClusterClientStreamingRegressionTests
{
    [Fact]
    public void CentralCommunicationActor_DoesNotHave_HandleDebugStreamEvent()
    {
        var type = typeof(CentralCommunicationActor);
        var method = type.GetMethod("HandleDebugStreamEvent",
            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
        Assert.Null(method);
    }

    [Fact]
    public void SiteCommunicationActor_DoesNotHave_HandleDebugStreamEvent()
    {
        var type = typeof(SiteCommunicationActor);
        var method = type.GetMethod("HandleDebugStreamEvent",
            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
        Assert.Null(method);
    }

    [Fact]
    public void CentralCommunicationActor_DoesNotHave_ForwardDebugStreamEvent()
    {
        var type = typeof(CentralCommunicationActor);
        var method = type.GetMethod("ForwardDebugStreamEvent",
            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
        Assert.Null(method);
    }

    [Fact]
    public void Communication_Assembly_DoesNotContain_DebugStreamEvent_Type()
    {
        // DebugStreamEvent should not exist in the Communication assembly either
        var assembly = typeof(CentralCommunicationActor).Assembly;
        var type = assembly.GetTypes().FirstOrDefault(t => t.Name == "DebugStreamEvent");
        Assert.Null(type);
    }
}
