Files
lmxopcua/tests/ZB.MOM.WW.LmxOpcUa.Tests/Wiring/OpcUaWriteToMxAccessWiringTest.cs
Joseph Doherty 41a6b66943 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>
2026-03-31 07:58:13 -04:00

52 lines
1.8 KiB
C#

using System.Collections.Generic;
using System.Threading.Tasks;
using Shouldly;
using Xunit;
using ZB.MOM.WW.LmxOpcUa.Host.Domain;
using ZB.MOM.WW.LmxOpcUa.Host.OpcUa;
using ZB.MOM.WW.LmxOpcUa.Tests.Helpers;
namespace ZB.MOM.WW.LmxOpcUa.Tests.Wiring
{
/// <summary>
/// Verifies: OPC UA Write → NodeManager → IMxAccessClient.WriteAsync with correct tag+value
/// </summary>
public class OpcUaWriteToMxAccessWiringTest
{
/// <summary>
/// Confirms that the resolved OPC UA write path targets the expected Galaxy tag reference and payload.
/// </summary>
[Fact]
public async Task Write_SendsCorrectTagAndValue()
{
var mxClient = new FakeMxAccessClient();
var hierarchy = new List<GalaxyObjectInfo>
{
new()
{
GobjectId = 1, TagName = "TestMachine_001", BrowseName = "TestMachine_001", ParentGobjectId = 0,
IsArea = false
}
};
var attributes = new List<GalaxyAttributeInfo>
{
new()
{
GobjectId = 1, TagName = "TestMachine_001", AttributeName = "MachineCode",
FullTagReference = "TestMachine_001.MachineCode", MxDataType = 5, IsArray = false
}
};
var model = AddressSpaceBuilder.Build(hierarchy, attributes);
var tagRef = model.NodeIdToTagReference["TestMachine_001.MachineCode"];
// Write through MxAccessClient
var result = await mxClient.WriteAsync(tagRef, "NEW_CODE");
result.ShouldBe(true);
mxClient.WrittenValues.ShouldContain(w =>
w.Tag == "TestMachine_001.MachineCode" && (string)w.Value == "NEW_CODE");
}
}
}