Renames all 11 projects (5 src + 6 tests), the .slnx solution file, all source-file namespaces, all axaml namespace references, and all v1 documentation references in CLAUDE.md and docs/*.md (excluding docs/v2/ which is already in OtOpcUa form). Also updates the TopShelf service registration name from "LmxOpcUa" to "OtOpcUa" per Phase 0 Task 0.6.
Preserves runtime identifiers per Phase 0 Out-of-Scope rules to avoid breaking v1/v2 client trust during coexistence: OPC UA `ApplicationUri` defaults (`urn:{GalaxyName}:LmxOpcUa`), server `EndpointPath` (`/LmxOpcUa`), `ServerName` default (feeds cert subject CN), `MxAccessConfiguration.ClientName` default (defensive — stays "LmxOpcUa" for MxAccess audit-trail consistency), client OPC UA identifiers (`ApplicationName = "LmxOpcUaClient"`, `ApplicationUri = "urn:localhost:LmxOpcUaClient"`, cert directory `%LocalAppData%\LmxOpcUaClient\pki\`), and the `LmxOpcUaServer` class name (class rename out of Phase 0 scope per Task 0.5 sed pattern; happens in Phase 1 alongside `LmxNodeManager → GenericDriverNodeManager` Core extraction). 23 LmxOpcUa references retained, all enumerated and justified in `docs/v2/implementation/exit-gate-phase-0.md`.
Build clean: 0 errors, 30 warnings (lower than baseline 167). Tests at strict improvement over baseline: 821 passing / 1 failing vs baseline 820 / 2 (one flaky pre-existing failure passed this run; the other still fails — both pre-existing and unrelated to the rename). `Client.UI.Tests`, `Historian.Aveva.Tests`, `Client.Shared.Tests`, `IntegrationTests` all match baseline exactly. Exit gate compliance results recorded in `docs/v2/implementation/exit-gate-phase-0.md` with all 7 checks PASS or DEFERRED-to-PR-review (#7 service install verification needs Windows service permissions on the reviewer's box).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
184 lines
7.8 KiB
C#
184 lines
7.8 KiB
C#
using System.Collections.Generic;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Host.Domain;
|
|
using ZB.MOM.WW.OtOpcUa.Host.OpcUa;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Tests.OpcUa
|
|
{
|
|
/// <summary>
|
|
/// Verifies the in-memory address-space model built from Galaxy hierarchy and attribute rows.
|
|
/// </summary>
|
|
public class LmxNodeManagerBuildTests
|
|
{
|
|
/// <summary>
|
|
/// Creates representative Galaxy hierarchy and attribute rows for address-space builder tests.
|
|
/// </summary>
|
|
/// <returns>The hierarchy and attribute rows used by the tests.</returns>
|
|
private static (List<GalaxyObjectInfo> hierarchy, List<GalaxyAttributeInfo> attributes) CreateTestData()
|
|
{
|
|
var hierarchy = new List<GalaxyObjectInfo>
|
|
{
|
|
new()
|
|
{
|
|
GobjectId = 1, TagName = "DEV", ContainedName = "DEV", BrowseName = "DEV", ParentGobjectId = 0,
|
|
IsArea = true
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 2, TagName = "TestArea", ContainedName = "TestArea", BrowseName = "TestArea",
|
|
ParentGobjectId = 1, IsArea = true
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 3, TagName = "TestMachine_001", ContainedName = "TestMachine_001",
|
|
BrowseName = "TestMachine_001", ParentGobjectId = 2, IsArea = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 4, TagName = "DelmiaReceiver_001", ContainedName = "DelmiaReceiver",
|
|
BrowseName = "DelmiaReceiver", ParentGobjectId = 3, IsArea = false
|
|
}
|
|
};
|
|
|
|
var attributes = new List<GalaxyAttributeInfo>
|
|
{
|
|
new()
|
|
{
|
|
GobjectId = 3, TagName = "TestMachine_001", AttributeName = "MachineID",
|
|
FullTagReference = "TestMachine_001.MachineID", MxDataType = 5, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 4, TagName = "DelmiaReceiver_001", AttributeName = "DownloadPath",
|
|
FullTagReference = "DelmiaReceiver_001.DownloadPath", MxDataType = 5, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 4, TagName = "DelmiaReceiver_001", AttributeName = "JobStepNumber",
|
|
FullTagReference = "DelmiaReceiver_001.JobStepNumber", MxDataType = 2, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 3, TagName = "TestMachine_001", AttributeName = "BatchItems",
|
|
FullTagReference = "TestMachine_001.BatchItems[]", MxDataType = 5, IsArray = true,
|
|
ArrayDimension = 50
|
|
}
|
|
};
|
|
|
|
return (hierarchy, attributes);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that object and variable counts are computed correctly from the seeded Galaxy model.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_CreatesCorrectNodeCounts()
|
|
{
|
|
var (hierarchy, attributes) = CreateTestData();
|
|
var model = AddressSpaceBuilder.Build(hierarchy, attributes);
|
|
|
|
model.ObjectCount.ShouldBe(2); // TestMachine_001, DelmiaReceiver
|
|
model.VariableCount.ShouldBe(4); // MachineID, DownloadPath, JobStepNumber, BatchItems
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that runtime tag references are populated for every published variable.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_TagReferencesPopulated()
|
|
{
|
|
var (hierarchy, attributes) = CreateTestData();
|
|
var model = AddressSpaceBuilder.Build(hierarchy, attributes);
|
|
|
|
model.NodeIdToTagReference.ContainsKey("TestMachine_001.MachineID").ShouldBe(true);
|
|
model.NodeIdToTagReference.ContainsKey("DelmiaReceiver_001.DownloadPath").ShouldBe(true);
|
|
model.NodeIdToTagReference.ContainsKey("DelmiaReceiver_001.JobStepNumber").ShouldBe(true);
|
|
model.NodeIdToTagReference.ContainsKey("TestMachine_001.BatchItems").ShouldBe(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that array attributes are represented in the tag-reference map.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_ArrayVariable_HasCorrectInfo()
|
|
{
|
|
var (hierarchy, attributes) = CreateTestData();
|
|
var model = AddressSpaceBuilder.Build(hierarchy, attributes);
|
|
|
|
model.NodeIdToTagReference.ContainsKey("TestMachine_001.BatchItems").ShouldBe(true);
|
|
model.NodeIdToTagReference["TestMachine_001.BatchItems"].ShouldBe("TestMachine_001.BatchItems[]");
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that Galaxy areas are not counted as object nodes in the resulting model.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_Areas_AreNotCountedAsObjects()
|
|
{
|
|
var hierarchy = new List<GalaxyObjectInfo>
|
|
{
|
|
new() { GobjectId = 1, TagName = "Area1", BrowseName = "Area1", ParentGobjectId = 0, IsArea = true },
|
|
new() { GobjectId = 2, TagName = "Obj1", BrowseName = "Obj1", ParentGobjectId = 1, IsArea = false }
|
|
};
|
|
|
|
var model = AddressSpaceBuilder.Build(hierarchy, new List<GalaxyAttributeInfo>());
|
|
model.ObjectCount.ShouldBe(1); // Only Obj1, not Area1
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that only top-level Galaxy nodes are returned as roots in the model.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_RootNodes_AreTopLevel()
|
|
{
|
|
var hierarchy = new List<GalaxyObjectInfo>
|
|
{
|
|
new() { GobjectId = 1, TagName = "Root1", BrowseName = "Root1", ParentGobjectId = 0, IsArea = true },
|
|
new() { GobjectId = 2, TagName = "Child1", BrowseName = "Child1", ParentGobjectId = 1, IsArea = false }
|
|
};
|
|
|
|
var model = AddressSpaceBuilder.Build(hierarchy, new List<GalaxyAttributeInfo>());
|
|
model.RootNodes.Count.ShouldBe(1); // Only Root1 is a root
|
|
}
|
|
|
|
/// <summary>
|
|
/// Confirms that variables for multiple MX data types are included in the model.
|
|
/// </summary>
|
|
[Fact]
|
|
public void BuildAddressSpace_DataTypeMappings()
|
|
{
|
|
var hierarchy = new List<GalaxyObjectInfo>
|
|
{
|
|
new() { GobjectId = 1, TagName = "Obj", BrowseName = "Obj", ParentGobjectId = 0, IsArea = false }
|
|
};
|
|
var attributes = new List<GalaxyAttributeInfo>
|
|
{
|
|
new()
|
|
{
|
|
GobjectId = 1, TagName = "Obj", AttributeName = "BoolAttr", FullTagReference = "Obj.BoolAttr",
|
|
MxDataType = 1, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 1, TagName = "Obj", AttributeName = "IntAttr", FullTagReference = "Obj.IntAttr",
|
|
MxDataType = 2, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 1, TagName = "Obj", AttributeName = "FloatAttr", FullTagReference = "Obj.FloatAttr",
|
|
MxDataType = 3, IsArray = false
|
|
},
|
|
new()
|
|
{
|
|
GobjectId = 1, TagName = "Obj", AttributeName = "StrAttr", FullTagReference = "Obj.StrAttr",
|
|
MxDataType = 5, IsArray = false
|
|
}
|
|
};
|
|
|
|
var model = AddressSpaceBuilder.Build(hierarchy, attributes);
|
|
model.VariableCount.ShouldBe(4);
|
|
model.NodeIdToTagReference.Count.ShouldBe(4);
|
|
}
|
|
}
|
|
} |