diff --git a/clients/dotnet/ZB.MOM.WW.MxGateway.Client.Tests/BrowseChildrenSmokeTests.cs b/clients/dotnet/ZB.MOM.WW.MxGateway.Client.Tests/BrowseChildrenSmokeTests.cs new file mode 100644 index 0000000..dd5f48e --- /dev/null +++ b/clients/dotnet/ZB.MOM.WW.MxGateway.Client.Tests/BrowseChildrenSmokeTests.cs @@ -0,0 +1,34 @@ +using Grpc.Core; +using Grpc.Net.Client; +using ZB.MOM.WW.MxGateway.Contracts.Proto.Galaxy; + +namespace ZB.MOM.WW.MxGateway.Client.Tests; + +/// +/// Live smoke tests for the BrowseChildren RPC. Skipped by default; set +/// MXGATEWAY_API_KEY and MXGATEWAY_ENDPOINT to run against a real gateway. +/// +public sealed class BrowseChildrenSmokeTests +{ + /// + /// Verifies that BrowseChildren returns a non-zero cache sequence and + /// a consistent children/child-has-children count from a live gateway. + /// + [Fact(Skip = "Set MXGATEWAY_API_KEY and MXGATEWAY_ENDPOINT to enable.")] + public async Task BrowseChildren_LiveGateway_ReturnsRootsWithCacheSequence() + { + string? apiKey = Environment.GetEnvironmentVariable("MXGATEWAY_API_KEY"); + string endpoint = Environment.GetEnvironmentVariable("MXGATEWAY_ENDPOINT") ?? "http://localhost:5120"; + + Assert.False(string.IsNullOrEmpty(apiKey), "MXGATEWAY_API_KEY must be set."); + + using GrpcChannel channel = GrpcChannel.ForAddress(endpoint); + GalaxyRepository.GalaxyRepositoryClient client = new(channel); + + Metadata headers = new() { { "authorization", $"Bearer {apiKey}" } }; + BrowseChildrenReply reply = await client.BrowseChildrenAsync(new BrowseChildrenRequest(), headers); + + Assert.True(reply.CacheSequence > 0UL); + Assert.Equal(reply.Children.Count, reply.ChildHasChildren.Count); + } +}