The sibling mxaccessgw repo (clients/dotnet/) restored a proper client library + contracts under the new ZB.MOM.WW.MxGateway namespace, so the binary-vendoring stopgap from PR Driver.Galaxy-016 can unwind via plan #1 of libs/README.md. - csproj: replace <Reference HintPath="libs\MxGateway.*.dll"> with a ProjectReference into ..\..\..\..\mxaccessgw\clients\dotnet ZB.MOM.WW.MxGateway.Client\. The five backfill PackageReference shims (Google.Protobuf, Grpc.Core.Api, Grpc.Net.Client, Polly.Core, Microsoft.Extensions.Logging.Abstractions) are now transitive again. - Source: 'using MxGateway.X' -> 'using ZB.MOM.WW.MxGateway.X' across 19 driver files + 14 test files. No fully-qualified MxGateway.* usages in code, so no behavioural changes — purely a using-prefix flip. - libs/: deleted MxGateway.Client.dll, MxGateway.Contracts.dll, README.md (orphan after the unwind). Verified: dotnet build clean (Release), all 245 Driver.Galaxy unit tests pass, OtOpcUa service running with the new client DLL loaded (opc.tcp://localhost:4840/OtOpcUa, no FileNotFound/TypeLoad/ MissingMethod in startup logs). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
108 lines
3.2 KiB
C#
108 lines
3.2 KiB
C#
using Google.Protobuf;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using ZB.MOM.WW.MxGateway.Contracts.Proto;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Runtime;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Galaxy.Tests.Runtime;
|
|
|
|
/// <summary>
|
|
/// Round-trip tests for <see cref="MxValueDecoder"/>. Each scenario constructs a
|
|
/// gateway-style <see cref="MxValue"/>, decodes, and asserts the boxed CLR value
|
|
/// matches the expected type and value.
|
|
/// </summary>
|
|
public sealed class MxValueDecoderTests
|
|
{
|
|
[Fact]
|
|
public void Decode_Null_ReturnsNull()
|
|
{
|
|
MxValueDecoder.Decode(null).ShouldBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_IsNullFlag_ReturnsNull()
|
|
{
|
|
var v = new MxValue { IsNull = true };
|
|
MxValueDecoder.Decode(v).ShouldBeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_Bool() => MxValueDecoder.Decode(new MxValue { BoolValue = true }).ShouldBe(true);
|
|
|
|
[Fact]
|
|
public void Decode_Int32() => MxValueDecoder.Decode(new MxValue { Int32Value = -42 }).ShouldBe(-42);
|
|
|
|
[Fact]
|
|
public void Decode_Int64() => MxValueDecoder.Decode(new MxValue { Int64Value = 123456789012L }).ShouldBe(123456789012L);
|
|
|
|
[Fact]
|
|
public void Decode_Float() => MxValueDecoder.Decode(new MxValue { FloatValue = 3.14f }).ShouldBe(3.14f);
|
|
|
|
[Fact]
|
|
public void Decode_Double() => MxValueDecoder.Decode(new MxValue { DoubleValue = 2.71828 }).ShouldBe(2.71828);
|
|
|
|
[Fact]
|
|
public void Decode_String() => MxValueDecoder.Decode(new MxValue { StringValue = "hello" }).ShouldBe("hello");
|
|
|
|
[Fact]
|
|
public void Decode_Timestamp_ReturnsUtcDateTime()
|
|
{
|
|
var when = new DateTime(2026, 4, 29, 12, 0, 0, DateTimeKind.Utc);
|
|
var v = new MxValue { TimestampValue = Timestamp.FromDateTime(when) };
|
|
MxValueDecoder.Decode(v).ShouldBe(when);
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_BoolArray()
|
|
{
|
|
var v = new MxValue
|
|
{
|
|
ArrayValue = new MxArray
|
|
{
|
|
BoolValues = new BoolArray(),
|
|
},
|
|
};
|
|
v.ArrayValue.BoolValues.Values.AddRange(new[] { true, false, true });
|
|
|
|
var decoded = MxValueDecoder.Decode(v);
|
|
decoded.ShouldBe(new[] { true, false, true });
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_DoubleArray()
|
|
{
|
|
var v = new MxValue
|
|
{
|
|
ArrayValue = new MxArray { DoubleValues = new DoubleArray() },
|
|
};
|
|
v.ArrayValue.DoubleValues.Values.AddRange(new[] { 1.0, 2.0, 3.5 });
|
|
|
|
var decoded = MxValueDecoder.Decode(v);
|
|
decoded.ShouldBe(new[] { 1.0, 2.0, 3.5 });
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_StringArray()
|
|
{
|
|
var v = new MxValue
|
|
{
|
|
ArrayValue = new MxArray { StringValues = new StringArray() },
|
|
};
|
|
v.ArrayValue.StringValues.Values.AddRange(new[] { "a", "b" });
|
|
|
|
var decoded = MxValueDecoder.Decode(v);
|
|
decoded.ShouldBe(new[] { "a", "b" });
|
|
}
|
|
|
|
[Fact]
|
|
public void Decode_RawValue_ReturnsBytes()
|
|
{
|
|
var bytes = new byte[] { 0xDE, 0xAD, 0xBE, 0xEF };
|
|
var v = new MxValue { RawValue = ByteString.CopyFrom(bytes) };
|
|
|
|
var decoded = (byte[])MxValueDecoder.Decode(v)!;
|
|
decoded.ShouldBe(bytes);
|
|
}
|
|
}
|