45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
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 GalaxyObjectInfo { GobjectId = 1, TagName = "TestMachine_001", BrowseName = "TestMachine_001", ParentGobjectId = 0, IsArea = false }
|
|
};
|
|
var attributes = new List<GalaxyAttributeInfo>
|
|
{
|
|
new GalaxyAttributeInfo { 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");
|
|
}
|
|
}
|
|
}
|