15bd409cdd
Since R06:M-5 the Sparkplug browser states no address for a metric the ingestor will not read and labels its descriptor 'not bindable', but the commit refusal still said the attribute lookup returned nothing. RawBrowseModal keeps the attribute's descriptor on the selection, and DescribeUncommittableLeaf reports a 'cannot be bound in this version' message echoing it. A lookup that really returned nothing keeps the old text. A test pins the marker to the browser's own string. Refs #745 Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
59 lines
2.7 KiB
C#
59 lines
2.7 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns;
|
|
|
|
/// <summary>
|
|
/// G2-F2: a Sparkplug array / unsupported-type metric is refused at commit with a "not bindable in this
|
|
/// version" message that echoes the browser's descriptor — not the "attribute lookup returned nothing"
|
|
/// text, which is reserved for a lookup that really did return nothing.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class MqttUnbindableLeafMessageTests
|
|
{
|
|
[Fact]
|
|
public void An_array_metric_says_it_is_not_bindable_and_echoes_the_descriptor()
|
|
{
|
|
const string descriptor = "Metric · Int32Array · alias 7 · array metrics are not read in v1 — not bindable";
|
|
|
|
var error = RawBrowseCommitMapper.DescribeUncommittableLeaf("Mqtt", "Pressures", addressFields: null, descriptor);
|
|
|
|
error.ShouldNotBeNull();
|
|
error!.ShouldContain("'Pressures' cannot be bound in this version");
|
|
error.ShouldContain(descriptor);
|
|
error.ShouldNotContain("attribute lookup returned nothing");
|
|
}
|
|
|
|
[Fact]
|
|
public void A_lookup_that_returned_nothing_keeps_the_original_message()
|
|
{
|
|
// Positive control: the new branch is selected by the descriptor, not by MQTT in general.
|
|
RawBrowseCommitMapper.DescribeUncommittableLeaf("Mqtt", "Temperature", addressFields: null, descriptor: null)!
|
|
.ShouldContain("attribute lookup returned nothing");
|
|
RawBrowseCommitMapper.DescribeUncommittableLeaf("Mqtt", "Temperature", null, "Metric · Double")!
|
|
.ShouldContain("attribute lookup returned nothing");
|
|
}
|
|
|
|
[Fact]
|
|
public void A_bindable_leaf_is_never_refused_whatever_its_descriptor_says()
|
|
=> RawBrowseCommitMapper.DescribeUncommittableLeaf(
|
|
"Mqtt", "Temperature",
|
|
new Dictionary<string, string> { [ZB.MOM.WW.OtOpcUa.Driver.Mqtt.MqttTagConfigKeys.MetricName] = "Temperature" },
|
|
"anything · not bindable")
|
|
.ShouldBeNull();
|
|
|
|
[Fact]
|
|
public void The_marker_matches_what_the_sparkplug_browser_writes()
|
|
{
|
|
var dir = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (dir is not null && !File.Exists(Path.Combine(dir.FullName, "ZB.MOM.WW.OtOpcUa.slnx"))) dir = dir.Parent;
|
|
var browser = File.ReadAllText(Path.Combine(dir!.FullName, "src", "Drivers",
|
|
"ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser", "MqttBrowseSession.cs"));
|
|
|
|
browser.ShouldContain("— " + RawBrowseCommitMapper.NotBindableMarker + "\")");
|
|
AdminUiSource.Read("Components", "Shared", "Raw", "RawBrowseModal.razor")
|
|
.ShouldContain("DescribeUncommittableLeaf(_driverType, s.Name, s.AddressFields, s.Descriptor)");
|
|
}
|
|
}
|