feat(sphistorianclient): port SDK source + tests, rebrand namespace to ZB.MOM.WW.SPHistorianClient
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
using ZB.MOM.WW.SPHistorianClient.Wcf;
|
||||
|
||||
namespace ZB.MOM.WW.SPHistorianClient.Tests;
|
||||
|
||||
public sealed class WcfStatusProtocolTests
|
||||
{
|
||||
[Fact]
|
||||
public void SystemTimeParserReadsWindowsSystemTimeLayout()
|
||||
{
|
||||
byte[] buffer =
|
||||
[
|
||||
0xEA, 0x07,
|
||||
0x04, 0x00,
|
||||
0x04, 0x00,
|
||||
0x1E, 0x00,
|
||||
0x0D, 0x00,
|
||||
0x2A, 0x00,
|
||||
0x07, 0x00,
|
||||
0x7B, 0x00
|
||||
];
|
||||
|
||||
DateTime? parsed = HistorianStatusProtocol.TryReadSystemTime(buffer);
|
||||
|
||||
Assert.Equal(new DateTime(2026, 4, 30, 13, 42, 7, 123), parsed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SystemTimeParserRejectsShortAndInvalidBuffers()
|
||||
{
|
||||
Assert.Null(HistorianStatusProtocol.TryReadSystemTime([0xEA, 0x07]));
|
||||
|
||||
byte[] invalidMonth =
|
||||
[
|
||||
0xEA, 0x07,
|
||||
0x00, 0x00,
|
||||
0x04, 0x00,
|
||||
0x1E, 0x00,
|
||||
0x0D, 0x00,
|
||||
0x2A, 0x00,
|
||||
0x07, 0x00,
|
||||
0x7B, 0x00
|
||||
];
|
||||
Assert.Null(HistorianStatusProtocol.TryReadSystemTime(invalidMonth));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user