feat(sphistorianclient): port SDK source + tests, rebrand namespace to ZB.MOM.WW.SPHistorianClient
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using ZB.MOM.WW.SPHistorianClient.Protocol;
|
||||
|
||||
namespace ZB.MOM.WW.SPHistorianClient.Tests;
|
||||
|
||||
public sealed class FrameTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task FrameWriterAndReader_RoundTrip()
|
||||
{
|
||||
HistorianFrame frame = new((HistorianMessageType)42, 123u, new byte[] { 1, 2, 3, 4 });
|
||||
byte[] bytes = HistorianFrameWriter.ToArray(frame);
|
||||
|
||||
HistorianFrame actual = await HistorianFrameReader.ReadAsync(new MemoryStream(bytes), CancellationToken.None);
|
||||
|
||||
Assert.Equal(frame.MessageType, actual.MessageType);
|
||||
Assert.Equal(frame.CorrelationId, actual.CorrelationId);
|
||||
Assert.True(frame.Payload.Span.SequenceEqual(actual.Payload.Span));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FrameReader_RejectsInvalidLength()
|
||||
{
|
||||
byte[] bytes = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
await Assert.ThrowsAsync<FrameFormatException>(async () =>
|
||||
await HistorianFrameReader.ReadAsync(new MemoryStream(bytes), CancellationToken.None));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user