46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
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));
|
|
}
|
|
}
|