39 lines
1.8 KiB
C#
39 lines
1.8 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
|
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
|
|
|
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "P09")]
|
|
public sealed class GrpcDataDiagnosticsTests
|
|
{
|
|
[Fact]
|
|
public void Sample_age_uses_the_node_observation_even_when_the_node_clock_is_ahead()
|
|
{
|
|
var consumerUtc = DateTime.UtcNow.AddSeconds(30);
|
|
var row = new ZB.MOM.WW.OtOpcUa.Commons.Interfaces.DataConnectionDiagnosticsSnapshot("link", 1, "ready", null, null,
|
|
0, 0, 1, "artifact", consumerUtc, LastSampleAtUtc: consumerUtc.AddSeconds(-20), SampleAgeUpperBound: TimeSpan.FromSeconds(20));
|
|
DataConnectionDiagnostics.SampleAge(row).ShouldBe("20s at observation");
|
|
}
|
|
|
|
[Fact]
|
|
public void Deleted_draft_remains_visible_while_applied_or_observed()
|
|
{
|
|
var draft = new DataConnection { DataConnectionId = "Peer", ClusterId = "MAIN" };
|
|
var before = DataConnectionDiagnostics.Rows([draft], ["peer"], ["PEER"]);
|
|
before.ShouldHaveSingleItem().Draft.ShouldBe(draft);
|
|
var after = DataConnectionDiagnostics.Rows([], ["peer"], ["PEER"]);
|
|
var retained = after.ShouldHaveSingleItem();
|
|
retained.Id.ShouldBe("peer");
|
|
retained.Draft.ShouldBeNull();
|
|
DataConnectionDiagnostics.Rows([], [], ["peer"]).ShouldHaveSingleItem();
|
|
DataConnectionDiagnostics.Rows([], [], []).ShouldBeEmpty();
|
|
}
|
|
[Fact]
|
|
public void Unknown_runtime_status_is_not_reported_as_ready() => DataConnectionDiagnostics.State(null).ShouldBe("Unavailable");
|
|
[Fact]
|
|
public void Endpoint_display_never_includes_credentials_or_query() =>
|
|
DataConnectionDiagnostics.Endpoint("https://user:password@example.com:8443/path?token=secret").ShouldBe("https://example.com:8443");
|
|
}
|