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

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

/// <summary>
///     A compile-touch test: it exists so that the repo's first locally-compiled proto
///     (<c>deployment_artifact.proto</c>) is proven to generate both the client stub and the server
///     base and the message types. If Grpc.Tools codegen regresses, this file stops compiling —
///     which, under TreatWarningsAsErrors, breaks the build loudly rather than silently.
/// </summary>
public class DeploymentArtifactProtoTests
{
    [Fact]
    public void The_request_message_carries_the_deployment_id()
    {
        var request = new FetchRequest { DeploymentId = "abc" };

        request.DeploymentId.ShouldBe("abc");
    }

    [Fact]
    public void The_chunk_message_carries_bytes()
    {
        var chunk = new ArtifactChunk { Data = Google.Protobuf.ByteString.CopyFromUtf8("x") };

        chunk.Data.Length.ShouldBe(1);
    }

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