feat(mesh-phase5): telemetry.proto contract + oneof + contract-lock test

Claude-Session: https://claude.ai/code/session_01GASWkNEi68FSCtvr6rLoEW
This commit is contained in:
Joseph Doherty
2026-07-23 14:58:53 -04:00
parent 094c29d13d
commit a845a6d2fd
4 changed files with 141 additions and 0 deletions
@@ -0,0 +1,32 @@
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();
}
}