feat(historian): carry isHistorized + historianTagname through EquipmentTagPlan (byte-parity)

This commit is contained in:
Joseph Doherty
2026-06-14 18:55:04 -04:00
parent fb906f26ac
commit 440929c82a
4 changed files with 271 additions and 3 deletions
@@ -0,0 +1,33 @@
using Shouldly;
using Xunit;
using ZB.MOM.WW.OtOpcUa.OpcUaServer;
namespace ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests;
public class ExtractTagHistorizeTests
{
[Theory]
// isHistorized true, no explicit tagname ⇒ tagname null (defaults to FullName later).
[InlineData("{\"FullName\":\"T.A\",\"isHistorized\":true}", true, null)]
// isHistorized true with an explicit historian-tagname override.
[InlineData("{\"FullName\":\"T.A\",\"isHistorized\":true,\"historianTagname\":\"WW.Tag\"}", true, "WW.Tag")]
// Absent isHistorized ⇒ false.
[InlineData("{\"FullName\":\"T.A\"}", false, null)]
// historianTagname parses independently of the flag.
[InlineData("{\"FullName\":\"T.A\",\"isHistorized\":false,\"historianTagname\":\"WW.Tag\"}", false, "WW.Tag")]
// Blank/whitespace tagname ⇒ null.
[InlineData("{\"FullName\":\"T.A\",\"isHistorized\":true,\"historianTagname\":\" \"}", true, null)]
// null / empty / malformed-JSON / array-root ⇒ (false, null), never throws.
[InlineData(null, false, null)]
[InlineData("", false, null)]
[InlineData("not json {", false, null)]
[InlineData("[1,2]", false, null)]
// Wrong type for isHistorized (string, not bool) ⇒ false.
[InlineData("{\"isHistorized\":\"yes\"}", false, null)]
public void ExtractTagHistorize_parses_or_returns_defaults(string? cfg, bool expectedHistorized, string? expectedTagname)
{
var (isHistorized, historianTagname) = Phase7Composer.ExtractTagHistorize(cfg);
isHistorized.ShouldBe(expectedHistorized);
historianTagname.ShouldBe(expectedTagname);
}
}