Apply code style formatting and restore partial modifiers on Avalonia views

Linter/formatter pass across the full codebase. Restores required partial
keyword on AXAML code-behind classes that the formatter incorrectly removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-03-31 07:58:13 -04:00
parent 55ef854612
commit 41a6b66943
221 changed files with 4274 additions and 3823 deletions

View File

@@ -9,13 +9,25 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
public class AddressSpaceDiffTests
{
private static GalaxyObjectInfo Obj(int id, string tag, int parent = 0, bool isArea = false)
=> new GalaxyObjectInfo { GobjectId = id, TagName = tag, BrowseName = tag, ContainedName = tag, ParentGobjectId = parent, IsArea = isArea };
{
return new GalaxyObjectInfo
{
GobjectId = id, TagName = tag, BrowseName = tag, ContainedName = tag, ParentGobjectId = parent,
IsArea = isArea
};
}
private static GalaxyAttributeInfo Attr(int gobjectId, string name, string tagName = "Obj", int mxDataType = 5)
=> new GalaxyAttributeInfo { GobjectId = gobjectId, AttributeName = name, FullTagReference = $"{tagName}.{name}", MxDataType = mxDataType, TagName = tagName };
{
return new GalaxyAttributeInfo
{
GobjectId = gobjectId, AttributeName = name, FullTagReference = $"{tagName}.{name}",
MxDataType = mxDataType, TagName = tagName
};
}
/// <summary>
/// Verifies that identical Galaxy hierarchy and attribute snapshots produce no incremental rebuild work.
/// Verifies that identical Galaxy hierarchy and attribute snapshots produce no incremental rebuild work.
/// </summary>
[Fact]
public void NoChanges_ReturnsEmptySet()
@@ -28,7 +40,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that newly deployed Galaxy objects are flagged for OPC UA subtree creation.
/// Verifies that newly deployed Galaxy objects are flagged for OPC UA subtree creation.
/// </summary>
[Fact]
public void AddedObject_Detected()
@@ -43,7 +55,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that removed Galaxy objects are flagged so their OPC UA subtree can be torn down.
/// Verifies that removed Galaxy objects are flagged so their OPC UA subtree can be torn down.
/// </summary>
[Fact]
public void RemovedObject_Detected()
@@ -58,13 +70,14 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that browse-name changes are treated as address-space changes for the affected Galaxy object.
/// Verifies that browse-name changes are treated as address-space changes for the affected Galaxy object.
/// </summary>
[Fact]
public void ModifiedObject_BrowseNameChange_Detected()
{
var oldH = new List<GalaxyObjectInfo> { Obj(1, "A") };
var newH = new List<GalaxyObjectInfo> { new GalaxyObjectInfo { GobjectId = 1, TagName = "A", BrowseName = "A_Renamed", ContainedName = "A" } };
var newH = new List<GalaxyObjectInfo>
{ new() { GobjectId = 1, TagName = "A", BrowseName = "A_Renamed", ContainedName = "A" } };
var a = new List<GalaxyAttributeInfo>();
var changed = AddressSpaceDiff.FindChangedGobjectIds(oldH, a, newH, a);
@@ -72,13 +85,17 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that parent changes are treated as subtree moves that require rebuilding the affected object.
/// Verifies that parent changes are treated as subtree moves that require rebuilding the affected object.
/// </summary>
[Fact]
public void ModifiedObject_ParentChange_Detected()
{
var oldH = new List<GalaxyObjectInfo> { Obj(1, "A"), Obj(2, "B", parent: 1) };
var newH = new List<GalaxyObjectInfo> { Obj(1, "A"), new GalaxyObjectInfo { GobjectId = 2, TagName = "B", BrowseName = "B", ContainedName = "B", ParentGobjectId = 0 } };
var oldH = new List<GalaxyObjectInfo> { Obj(1, "A"), Obj(2, "B", 1) };
var newH = new List<GalaxyObjectInfo>
{
Obj(1, "A"),
new() { GobjectId = 2, TagName = "B", BrowseName = "B", ContainedName = "B", ParentGobjectId = 0 }
};
var a = new List<GalaxyAttributeInfo>();
var changed = AddressSpaceDiff.FindChangedGobjectIds(oldH, a, newH, a);
@@ -86,7 +103,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that adding a Galaxy attribute marks the owning object for OPC UA variable rebuild.
/// Verifies that adding a Galaxy attribute marks the owning object for OPC UA variable rebuild.
/// </summary>
[Fact]
public void AttributeAdded_Detected()
@@ -100,7 +117,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that removing a Galaxy attribute marks the owning object for OPC UA variable rebuild.
/// Verifies that removing a Galaxy attribute marks the owning object for OPC UA variable rebuild.
/// </summary>
[Fact]
public void AttributeRemoved_Detected()
@@ -114,7 +131,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that changes to attribute field metadata such as MX data type trigger rebuild of the owning object.
/// Verifies that changes to attribute field metadata such as MX data type trigger rebuild of the owning object.
/// </summary>
[Fact]
public void AttributeFieldChange_Detected()
@@ -128,21 +145,23 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that security-classification changes are treated as address-space changes for the owning attribute.
/// Verifies that security-classification changes are treated as address-space changes for the owning attribute.
/// </summary>
[Fact]
public void AttributeSecurityChange_Detected()
{
var h = new List<GalaxyObjectInfo> { Obj(1, "A") };
var oldA = new List<GalaxyAttributeInfo> { new GalaxyAttributeInfo { GobjectId = 1, AttributeName = "X", FullTagReference = "A.X", SecurityClassification = 1 } };
var newA = new List<GalaxyAttributeInfo> { new GalaxyAttributeInfo { GobjectId = 1, AttributeName = "X", FullTagReference = "A.X", SecurityClassification = 2 } };
var oldA = new List<GalaxyAttributeInfo>
{ new() { GobjectId = 1, AttributeName = "X", FullTagReference = "A.X", SecurityClassification = 1 } };
var newA = new List<GalaxyAttributeInfo>
{ new() { GobjectId = 1, AttributeName = "X", FullTagReference = "A.X", SecurityClassification = 2 } };
var changed = AddressSpaceDiff.FindChangedGobjectIds(h, oldA, h, newA);
changed.ShouldContain(1);
}
/// <summary>
/// Verifies that subtree expansion includes all descendants of a changed Galaxy object.
/// Verifies that subtree expansion includes all descendants of a changed Galaxy object.
/// </summary>
[Fact]
public void ExpandToSubtrees_IncludesChildren()
@@ -150,9 +169,9 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
var h = new List<GalaxyObjectInfo>
{
Obj(1, "Root"),
Obj(2, "Child", parent: 1),
Obj(3, "Grandchild", parent: 2),
Obj(4, "Sibling", parent: 1),
Obj(2, "Child", 1),
Obj(3, "Grandchild", 2),
Obj(4, "Sibling", 1),
Obj(5, "Unrelated")
};
@@ -167,7 +186,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Verifies that subtree expansion does not introduce unrelated nodes when the changed object is already a leaf.
/// Verifies that subtree expansion does not introduce unrelated nodes when the changed object is already a leaf.
/// </summary>
[Fact]
public void ExpandToSubtrees_LeafNode_NoExpansion()
@@ -175,8 +194,8 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
var h = new List<GalaxyObjectInfo>
{
Obj(1, "Root"),
Obj(2, "Child", parent: 1),
Obj(3, "Sibling", parent: 1)
Obj(2, "Child", 1),
Obj(3, "Sibling", 1)
};
var changed = new HashSet<int> { 2 };
@@ -187,4 +206,4 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
expanded.ShouldNotContain(3);
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using Opc.Ua;
using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Host.Domain;
@@ -7,12 +8,12 @@ using ZB.MOM.WW.LmxOpcUa.Host.OpcUa;
namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
{
/// <summary>
/// Verifies how bridge VTQ values are translated to and from OPC UA data values for the published namespace.
/// Verifies how bridge VTQ values are translated to and from OPC UA data values for the published namespace.
/// </summary>
public class DataValueConverterTests
{
/// <summary>
/// Confirms that boolean runtime values are preserved when converted to OPC UA data values.
/// Confirms that boolean runtime values are preserved when converted to OPC UA data values.
/// </summary>
[Fact]
public void FromVtq_Boolean()
@@ -20,11 +21,11 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
var vtq = Vtq.Good(true);
var dv = DataValueConverter.FromVtq(vtq);
dv.Value.ShouldBe(true);
Opc.Ua.StatusCode.IsGood(dv.StatusCode).ShouldBe(true);
StatusCode.IsGood(dv.StatusCode).ShouldBe(true);
}
/// <summary>
/// Confirms that integer runtime values are preserved when converted to OPC UA data values.
/// Confirms that integer runtime values are preserved when converted to OPC UA data values.
/// </summary>
[Fact]
public void FromVtq_Int32()
@@ -35,7 +36,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that float runtime values are preserved when converted to OPC UA data values.
/// Confirms that float runtime values are preserved when converted to OPC UA data values.
/// </summary>
[Fact]
public void FromVtq_Float()
@@ -46,7 +47,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that double runtime values are preserved when converted to OPC UA data values.
/// Confirms that double runtime values are preserved when converted to OPC UA data values.
/// </summary>
[Fact]
public void FromVtq_Double()
@@ -57,7 +58,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that string runtime values are preserved when converted to OPC UA data values.
/// Confirms that string runtime values are preserved when converted to OPC UA data values.
/// </summary>
[Fact]
public void FromVtq_String()
@@ -68,7 +69,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that UTC timestamps remain UTC when a VTQ is converted for OPC UA clients.
/// Confirms that UTC timestamps remain UTC when a VTQ is converted for OPC UA clients.
/// </summary>
[Fact]
public void FromVtq_DateTime_IsUtc()
@@ -80,7 +81,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that elapsed-time values are exposed to OPC UA clients in seconds.
/// Confirms that elapsed-time values are exposed to OPC UA clients in seconds.
/// </summary>
[Fact]
public void FromVtq_TimeSpan_ConvertedToSeconds()
@@ -91,7 +92,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that string arrays remain arrays when exposed through OPC UA.
/// Confirms that string arrays remain arrays when exposed through OPC UA.
/// </summary>
[Fact]
public void FromVtq_StringArray()
@@ -103,7 +104,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that integer arrays remain arrays when exposed through OPC UA.
/// Confirms that integer arrays remain arrays when exposed through OPC UA.
/// </summary>
[Fact]
public void FromVtq_IntArray()
@@ -115,29 +116,29 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that bad runtime quality is translated to a bad OPC UA status code.
/// Confirms that bad runtime quality is translated to a bad OPC UA status code.
/// </summary>
[Fact]
public void FromVtq_BadQuality_MapsToStatusCode()
{
var vtq = Vtq.Bad(Quality.BadCommFailure);
var dv = DataValueConverter.FromVtq(vtq);
Opc.Ua.StatusCode.IsBad(dv.StatusCode).ShouldBe(true);
StatusCode.IsBad(dv.StatusCode).ShouldBe(true);
}
/// <summary>
/// Confirms that uncertain runtime quality is translated to an uncertain OPC UA status code.
/// Confirms that uncertain runtime quality is translated to an uncertain OPC UA status code.
/// </summary>
[Fact]
public void FromVtq_UncertainQuality()
{
var vtq = Vtq.Uncertain(42);
var dv = DataValueConverter.FromVtq(vtq);
Opc.Ua.StatusCode.IsUncertain(dv.StatusCode).ShouldBe(true);
StatusCode.IsUncertain(dv.StatusCode).ShouldBe(true);
}
/// <summary>
/// Confirms that null runtime values remain null when converted for OPC UA.
/// Confirms that null runtime values remain null when converted for OPC UA.
/// </summary>
[Fact]
public void FromVtq_NullValue()
@@ -148,7 +149,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that a data value can round-trip back into a VTQ without losing the process value or quality.
/// Confirms that a data value can round-trip back into a VTQ without losing the process value or quality.
/// </summary>
[Fact]
public void ToVtq_RoundTrip()
@@ -161,4 +162,4 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
roundTrip.Quality.ShouldBe(Quality.Good);
}
}
}
}

View File

@@ -7,37 +7,70 @@ using ZB.MOM.WW.LmxOpcUa.Host.OpcUa;
namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
{
/// <summary>
/// Verifies the in-memory address-space model built from Galaxy hierarchy and attribute rows.
/// 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.
/// 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 GalaxyObjectInfo { GobjectId = 1, TagName = "DEV", ContainedName = "DEV", BrowseName = "DEV", ParentGobjectId = 0, IsArea = true },
new GalaxyObjectInfo { GobjectId = 2, TagName = "TestArea", ContainedName = "TestArea", BrowseName = "TestArea", ParentGobjectId = 1, IsArea = true },
new GalaxyObjectInfo { GobjectId = 3, TagName = "TestMachine_001", ContainedName = "TestMachine_001", BrowseName = "TestMachine_001", ParentGobjectId = 2, IsArea = false },
new GalaxyObjectInfo { GobjectId = 4, TagName = "DelmiaReceiver_001", ContainedName = "DelmiaReceiver", BrowseName = "DelmiaReceiver", ParentGobjectId = 3, IsArea = false },
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 GalaxyAttributeInfo { GobjectId = 3, TagName = "TestMachine_001", AttributeName = "MachineID", FullTagReference = "TestMachine_001.MachineID", MxDataType = 5, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 4, TagName = "DelmiaReceiver_001", AttributeName = "DownloadPath", FullTagReference = "DelmiaReceiver_001.DownloadPath", MxDataType = 5, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 4, TagName = "DelmiaReceiver_001", AttributeName = "JobStepNumber", FullTagReference = "DelmiaReceiver_001.JobStepNumber", MxDataType = 2, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 3, TagName = "TestMachine_001", AttributeName = "BatchItems", FullTagReference = "TestMachine_001.BatchItems[]", MxDataType = 5, IsArray = true, ArrayDimension = 50 },
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.
/// Confirms that object and variable counts are computed correctly from the seeded Galaxy model.
/// </summary>
[Fact]
public void BuildAddressSpace_CreatesCorrectNodeCounts()
@@ -50,7 +83,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that runtime tag references are populated for every published variable.
/// Confirms that runtime tag references are populated for every published variable.
/// </summary>
[Fact]
public void BuildAddressSpace_TagReferencesPopulated()
@@ -65,7 +98,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that array attributes are represented in the tag-reference map.
/// Confirms that array attributes are represented in the tag-reference map.
/// </summary>
[Fact]
public void BuildAddressSpace_ArrayVariable_HasCorrectInfo()
@@ -78,15 +111,15 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that Galaxy areas are not counted as object nodes in the resulting model.
/// 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 GalaxyObjectInfo { GobjectId = 1, TagName = "Area1", BrowseName = "Area1", ParentGobjectId = 0, IsArea = true },
new GalaxyObjectInfo { GobjectId = 2, TagName = "Obj1", BrowseName = "Obj1", ParentGobjectId = 1, IsArea = false }
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>());
@@ -94,15 +127,15 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that only top-level Galaxy nodes are returned as roots in the model.
/// 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 GalaxyObjectInfo { GobjectId = 1, TagName = "Root1", BrowseName = "Root1", ParentGobjectId = 0, IsArea = true },
new GalaxyObjectInfo { GobjectId = 2, TagName = "Child1", BrowseName = "Child1", ParentGobjectId = 1, IsArea = false }
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>());
@@ -110,21 +143,37 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that variables for multiple MX data types are included in the model.
/// 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 GalaxyObjectInfo { GobjectId = 1, TagName = "Obj", BrowseName = "Obj", ParentGobjectId = 0, IsArea = false }
new() { GobjectId = 1, TagName = "Obj", BrowseName = "Obj", ParentGobjectId = 0, IsArea = false }
};
var attributes = new List<GalaxyAttributeInfo>
{
new GalaxyAttributeInfo { GobjectId = 1, TagName = "Obj", AttributeName = "BoolAttr", FullTagReference = "Obj.BoolAttr", MxDataType = 1, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 1, TagName = "Obj", AttributeName = "IntAttr", FullTagReference = "Obj.IntAttr", MxDataType = 2, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 1, TagName = "Obj", AttributeName = "FloatAttr", FullTagReference = "Obj.FloatAttr", MxDataType = 3, IsArray = false },
new GalaxyAttributeInfo { GobjectId = 1, TagName = "Obj", AttributeName = "StrAttr", FullTagReference = "Obj.StrAttr", MxDataType = 5, IsArray = false },
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);
@@ -132,4 +181,4 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
model.NodeIdToTagReference.Count.ShouldBe(4);
}
}
}
}

View File

@@ -7,23 +7,27 @@ using ZB.MOM.WW.LmxOpcUa.Host.OpcUa;
namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
{
/// <summary>
/// Verifies rebuild behavior by comparing address-space models before and after metadata changes.
/// Verifies rebuild behavior by comparing address-space models before and after metadata changes.
/// </summary>
public class LmxNodeManagerRebuildTests
{
/// <summary>
/// Confirms that rebuilding with new metadata replaces the old tag-reference set.
/// Confirms that rebuilding with new metadata replaces the old tag-reference set.
/// </summary>
[Fact]
public void Rebuild_NewBuild_ReplacesOldData()
{
var hierarchy1 = new List<GalaxyObjectInfo>
{
new GalaxyObjectInfo { GobjectId = 1, TagName = "OldObj", BrowseName = "OldObj", ParentGobjectId = 0, IsArea = false }
new() { GobjectId = 1, TagName = "OldObj", BrowseName = "OldObj", ParentGobjectId = 0, IsArea = false }
};
var attrs1 = new List<GalaxyAttributeInfo>
{
new GalaxyAttributeInfo { GobjectId = 1, TagName = "OldObj", AttributeName = "OldAttr", FullTagReference = "OldObj.OldAttr", MxDataType = 5, IsArray = false }
new()
{
GobjectId = 1, TagName = "OldObj", AttributeName = "OldAttr", FullTagReference = "OldObj.OldAttr",
MxDataType = 5, IsArray = false
}
};
var model1 = AddressSpaceBuilder.Build(hierarchy1, attrs1);
@@ -32,11 +36,15 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
// Rebuild with new data
var hierarchy2 = new List<GalaxyObjectInfo>
{
new GalaxyObjectInfo { GobjectId = 2, TagName = "NewObj", BrowseName = "NewObj", ParentGobjectId = 0, IsArea = false }
new() { GobjectId = 2, TagName = "NewObj", BrowseName = "NewObj", ParentGobjectId = 0, IsArea = false }
};
var attrs2 = new List<GalaxyAttributeInfo>
{
new GalaxyAttributeInfo { GobjectId = 2, TagName = "NewObj", AttributeName = "NewAttr", FullTagReference = "NewObj.NewAttr", MxDataType = 2, IsArray = false }
new()
{
GobjectId = 2, TagName = "NewObj", AttributeName = "NewAttr", FullTagReference = "NewObj.NewAttr",
MxDataType = 2, IsArray = false
}
};
var model2 = AddressSpaceBuilder.Build(hierarchy2, attrs2);
@@ -47,29 +55,29 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that object counts are recalculated from the latest rebuild input.
/// Confirms that object counts are recalculated from the latest rebuild input.
/// </summary>
[Fact]
public void Rebuild_UpdatesNodeCounts()
{
var hierarchy1 = new List<GalaxyObjectInfo>
{
new GalaxyObjectInfo { GobjectId = 1, TagName = "Obj1", BrowseName = "Obj1", ParentGobjectId = 0, IsArea = false },
new GalaxyObjectInfo { GobjectId = 2, TagName = "Obj2", BrowseName = "Obj2", ParentGobjectId = 0, IsArea = false }
new() { GobjectId = 1, TagName = "Obj1", BrowseName = "Obj1", ParentGobjectId = 0, IsArea = false },
new() { GobjectId = 2, TagName = "Obj2", BrowseName = "Obj2", ParentGobjectId = 0, IsArea = false }
};
var model1 = AddressSpaceBuilder.Build(hierarchy1, new List<GalaxyAttributeInfo>());
model1.ObjectCount.ShouldBe(2);
var hierarchy2 = new List<GalaxyObjectInfo>
{
new GalaxyObjectInfo { GobjectId = 3, TagName = "Obj3", BrowseName = "Obj3", ParentGobjectId = 0, IsArea = false }
new() { GobjectId = 3, TagName = "Obj3", BrowseName = "Obj3", ParentGobjectId = 0, IsArea = false }
};
var model2 = AddressSpaceBuilder.Build(hierarchy2, new List<GalaxyAttributeInfo>());
model2.ObjectCount.ShouldBe(1);
}
/// <summary>
/// Confirms that empty metadata produces an empty address-space model.
/// Confirms that empty metadata produces an empty address-space model.
/// </summary>
[Fact]
public void EmptyHierarchy_ProducesEmptyModel()
@@ -81,4 +89,4 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
model.VariableCount.ShouldBe(0);
}
}
}
}

View File

@@ -7,12 +7,12 @@ using ZB.MOM.WW.LmxOpcUa.Host.OpcUa;
namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
{
/// <summary>
/// Verifies translation between bridge quality values and OPC UA status codes.
/// Verifies translation between bridge quality values and OPC UA status codes.
/// </summary>
public class OpcUaQualityMapperTests
{
/// <summary>
/// Confirms that good bridge quality maps to an OPC UA good status.
/// Confirms that good bridge quality maps to an OPC UA good status.
/// </summary>
[Fact]
public void Good_MapsToGoodStatusCode()
@@ -22,7 +22,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that bad bridge quality maps to an OPC UA bad status.
/// Confirms that bad bridge quality maps to an OPC UA bad status.
/// </summary>
[Fact]
public void Bad_MapsToBadStatusCode()
@@ -32,7 +32,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that uncertain bridge quality maps to an OPC UA uncertain status.
/// Confirms that uncertain bridge quality maps to an OPC UA uncertain status.
/// </summary>
[Fact]
public void Uncertain_MapsToUncertainStatusCode()
@@ -42,7 +42,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that communication failures map to a bad OPC UA status code.
/// Confirms that communication failures map to a bad OPC UA status code.
/// </summary>
[Fact]
public void BadCommFailure_MapsCorrectly()
@@ -52,7 +52,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that the OPC UA good status maps back to bridge good quality.
/// Confirms that the OPC UA good status maps back to bridge good quality.
/// </summary>
[Fact]
public void FromStatusCode_Good()
@@ -62,7 +62,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that the OPC UA bad status maps back to bridge bad quality.
/// Confirms that the OPC UA bad status maps back to bridge bad quality.
/// </summary>
[Fact]
public void FromStatusCode_Bad()
@@ -72,7 +72,7 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
}
/// <summary>
/// Confirms that the OPC UA uncertain status maps back to bridge uncertain quality.
/// Confirms that the OPC UA uncertain status maps back to bridge uncertain quality.
/// </summary>
[Fact]
public void FromStatusCode_Uncertain()
@@ -81,4 +81,4 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.OpcUa
q.ShouldBe(Quality.Uncertain);
}
}
}
}