2fba036176
HistoryServed reads 'unavailable' when neither features nor variants were reported. Features() and DroppedBits() render every set bit across all 32 (bit 31 included), named when known and hex otherwise, so an unknown bit is never hidden beside a known one (#919).
65 lines
3.6 KiB
C#
65 lines
3.6 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
|
using ZB.MOM.WW.OtOpcUa.Commons.Interfaces;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
|
|
|
/// <summary>H4 diagnostics display (plan §6) and the X0 dropped-bit rendering (#919) on the data-connections page.</summary>
|
|
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "H4")]
|
|
public sealed class GrpcDataHistoryDiagnosticsDisplayTests
|
|
{
|
|
private static DataConnectionDiagnosticsSnapshot Row() =>
|
|
new("link", 1, "ready", null, null, 0, 0, 1, "artifact", DateTime.UtcNow);
|
|
|
|
[Fact]
|
|
public void Negotiated_features_distinguish_unavailable_v1_and_history()
|
|
{
|
|
DataConnectionDiagnostics.Features(null).ShouldBe("unavailable");
|
|
DataConnectionDiagnostics.Features(DataFeatures.None).ShouldBe("none (v1 behaviour)");
|
|
DataConnectionDiagnostics.Features(DataFeatures.History).ShouldBe("History");
|
|
DataConnectionDiagnostics.Features(DataFeatures.History | DataFeatures.Conditions).ShouldBe("History, Conditions");
|
|
// H4 review 6: an unknown bit is never hidden by a known one.
|
|
DataConnectionDiagnostics.Features(DataFeatures.History | (DataFeatures)8).ShouldBe("History, 0x8");
|
|
DataConnectionDiagnostics.Features((DataFeatures)int.MinValue).ShouldBe("0x80000000");
|
|
}
|
|
|
|
[Fact]
|
|
public void Origin_history_shows_the_advertised_variants_and_aggregate_count()
|
|
{
|
|
DataConnectionDiagnostics.HistoryServed(Row()).ShouldBe("unavailable", "no handshake evidence at all (H4 review 5)");
|
|
DataConnectionDiagnostics.HistoryServed(Row() with { NegotiatedFeatures = DataFeatures.None }).ShouldBe("not advertised");
|
|
DataConnectionDiagnostics.HistoryServed(Row() with { NegotiatedFeatures = DataFeatures.History, HistoryVariants = [] }).ShouldBe("advertised, no variant granted");
|
|
DataConnectionDiagnostics.HistoryServed(Row() with { HistoryVariants = ["raw", "processed", "attime"], HistoryAggregateCount = 12 })
|
|
.ShouldBe("raw, processed, attime (12 aggregates)");
|
|
}
|
|
|
|
[Fact]
|
|
public void History_counts_by_status_class_are_unavailable_from_an_older_node_not_zero()
|
|
{
|
|
DataConnectionDiagnostics.HistoryCounts(null, null, null).ShouldBe("unavailable");
|
|
DataConnectionDiagnostics.HistoryCounts(5, 0, 2).ShouldBe("good 5 · uncertain 0 · bad 2");
|
|
}
|
|
|
|
[Fact]
|
|
public void Dropped_bits_are_named_when_known_and_hex_when_not()
|
|
{
|
|
DataConnectionDiagnostics.DroppedBits(null).ShouldBe("unavailable");
|
|
DataConnectionDiagnostics.DroppedBits(DataOperations.None).ShouldBe("none");
|
|
DataConnectionDiagnostics.DroppedBits(DataOperations.HistoryRead | DataOperations.AlarmSubscribe).ShouldBe("HistoryRead, AlarmSubscribe");
|
|
DataConnectionDiagnostics.DroppedBits((DataOperations)(1 << 20)).ShouldBe("0x100000");
|
|
// H4 review 6: the full width, bit 31 included, beside a known bit.
|
|
DataConnectionDiagnostics.DroppedBits(DataOperations.HistoryRead | (DataOperations)int.MinValue).ShouldBe("HistoryRead, 0x80000000");
|
|
}
|
|
|
|
[Fact]
|
|
public void The_older_build_hint_shows_only_when_something_was_dropped()
|
|
{
|
|
DataConnectionDiagnostics.HasDrops(null).ShouldBeFalse();
|
|
DataConnectionDiagnostics.HasDrops(DataOperations.None, 0).ShouldBeFalse();
|
|
DataConnectionDiagnostics.HasDrops(DataOperations.HistoryRead).ShouldBeTrue();
|
|
DataConnectionDiagnostics.HasDrops(DataOperations.None, 2).ShouldBeTrue("a mapping's drop counts even when the connection dropped none");
|
|
}
|
|
}
|