using ZB.MOM.WW.MxGateway.Server.Galaxy; namespace ZB.MOM.WW.MxGateway.IntegrationTests.Galaxy; [Collection(LiveResourcesCollection.Name)] [Trait("Category", "LiveGalaxy")] public sealed class GalaxyRepositoryLiveTests { /// Verifies that the Galaxy Repository can establish a live connection to the ZB database. [LiveGalaxyRepositoryFact] public async Task TestConnection_AgainstZb_Succeeds() { GalaxyRepository repository = CreateRepository(); bool ok = await repository.TestConnectionAsync(CancellationToken.None); Assert.True(ok, "TestConnectionAsync should return true against the ZB database."); } /// Verifies that the last deploy time can be retrieved from the ZB database. [LiveGalaxyRepositoryFact] public async Task GetLastDeployTime_AgainstZb_ReturnsTimestamp() { GalaxyRepository repository = CreateRepository(); DateTime? lastDeploy = await repository.GetLastDeployTimeAsync(CancellationToken.None); Assert.NotNull(lastDeploy); } /// Verifies that the hierarchy can be retrieved from the ZB database. [LiveGalaxyRepositoryFact] public async Task GetHierarchy_AgainstZb_ReturnsObjects() { GalaxyRepository repository = CreateRepository(); List rows = await repository.GetHierarchyAsync(CancellationToken.None); Assert.NotEmpty(rows); Assert.All(rows, row => { Assert.True(row.GobjectId > 0); Assert.False(string.IsNullOrEmpty(row.TagName)); Assert.False(string.IsNullOrEmpty(row.BrowseName)); }); } /// Verifies that object attributes can be retrieved from the ZB database. [LiveGalaxyRepositoryFact] public async Task GetAttributes_AgainstZb_ReturnsAtLeastOneAttribute() { GalaxyRepository repository = CreateRepository(); List rows = await repository.GetAttributesAsync(CancellationToken.None); Assert.NotEmpty(rows); Assert.All(rows, row => { Assert.True(row.GobjectId > 0); Assert.False(string.IsNullOrEmpty(row.AttributeName)); Assert.False(string.IsNullOrEmpty(row.FullTagReference)); }); } private static GalaxyRepository CreateRepository() => new(new GalaxyRepositoryOptions { ConnectionString = LiveGalaxyRepositoryFactAttribute.ConnectionString, CommandTimeoutSeconds = 30, }); }