public async Task WriteAsync_WithPayload() { var(encoder, reader) = GetEncoder(); var frame = FrameProvider.GetFrame(4); await encoder.EncodeAsync(frame); var result = await reader.ReadAsync(); Assert.Equal(FrameProvider.HeaderSize + FrameProvider.FrameSize, result.Buffer.Length); }
public async Task ShouldDecodeOneFrame() { var(decoder, writer) = GetDecoder(); await FrameProvider.WriteFrame(writer, FrameProvider.GetFrame(4)); await foreach (var frame in decoder.DecodeAsync()) { Assert.Equal(4, frame.MessageId); Assert.Equal(FrameProvider.FrameSize, frame.Payload.Memory.Length); break; } }
public async Task ShouldDecode1024Frame() { var(decoder, writer) = GetDecoder(); var enumerator = decoder.DecodeAsync().GetAsyncEnumerator(); for (var i = 0; i < 1024; i++) { await FrameProvider.WriteFrame(writer, FrameProvider.GetFrame(i)); await enumerator.MoveNextAsync(); var frame = enumerator.Current; Assert.Equal(i, frame.MessageId); Assert.Equal(FrameProvider.FrameSize, frame.Payload.Memory.Length); } }