using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.Commons.Protos;
using ZB.MOM.WW.OtOpcUa.Commons.Protos.Telemetry.V1;

namespace ZB.MOM.WW.OtOpcUa.Commons.Tests;

/// <summary>
///     Contract-lock for the Phase 5 telemetry oneof. If a fifth variant is added to
///     <c>telemetry.proto</c> without adding a matching entry to
///     <see cref="TelemetryProtoContract.HandledCases"/>, this test goes red — the single guard that
///     keeps the wire contract and the handled-case set from silently drifting apart.
/// </summary>
public class TelemetryProtoContractTests
{
    [Fact]
    public void EveryOneofVariant_IsAccountedFor()
    {
        var variants = System.Enum.GetValues<TelemetryEvent.EventOneofCase>()
            .Where(c => c != TelemetryEvent.EventOneofCase.None).ToArray();

        variants.ShouldBe(TelemetryProtoContract.HandledCases, ignoreOrder: true);
    }

    [Fact]
    public void The_service_base_and_client_types_generate()
    {
        // Referencing these types is the whole assertion — GrpcServices="Both" must emit both.
        typeof(TelemetryStreamService.TelemetryStreamServiceBase).ShouldNotBeNull();
        typeof(TelemetryStreamService.TelemetryStreamServiceClient).ShouldNotBeNull();
    }
}
