feat(sphistorianclient): port SDK source + tests, rebrand namespace to ZB.MOM.WW.SPHistorianClient
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
using System.Text;
|
||||
using ZB.MOM.WW.SPHistorianClient.Protocol;
|
||||
|
||||
namespace ZB.MOM.WW.SPHistorianClient.Tests;
|
||||
|
||||
public sealed class BinaryPrimitiveTests
|
||||
{
|
||||
[Fact]
|
||||
public void ToFileTimeUtc_TreatsUnspecifiedAsUtc()
|
||||
{
|
||||
DateTime value = new(2020, 4, 5, 10, 7, 42, DateTimeKind.Unspecified);
|
||||
|
||||
long actual = HistorianBinaryPrimitives.ToFileTimeUtc(value);
|
||||
|
||||
Assert.Equal(DateTime.SpecifyKind(value, DateTimeKind.Utc).ToFileTimeUtc(), actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WriteUtf16NullTerminated_WritesUnicodeWithTerminator()
|
||||
{
|
||||
using MemoryStream stream = new();
|
||||
|
||||
HistorianBinaryPrimitives.WriteUtf16NullTerminated(stream, "UTC");
|
||||
|
||||
Assert.Equal(Encoding.Unicode.GetBytes("UTC\0"), stream.ToArray());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WriteFileTimeUtc_WritesLittleEndianUInt64()
|
||||
{
|
||||
DateTime value = new(2020, 4, 5, 10, 7, 42, DateTimeKind.Utc);
|
||||
using MemoryStream stream = new();
|
||||
|
||||
HistorianBinaryPrimitives.WriteFileTimeUtc(stream, value);
|
||||
|
||||
Assert.Equal(BitConverter.GetBytes(value.ToFileTimeUtc()), stream.ToArray());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user