52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Host.Domain;
|
|
using ZB.MOM.WW.OtOpcUa.Host.OpcUa;
|
|
using ZB.MOM.WW.OtOpcUa.Tests.Helpers;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.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");
|
|
}
|
|
}
|
|
} |