@@ -167,7 +167,8 @@ public void ShouldCleanupChunkBufferIfItExceedsMaxChunkBufferSize()
167167 real . Should ( ) . HaveCount ( ushort . MaxValue ) ;
168168 real . Should ( ) . Contain ( 0 ) ;
169169
170- chunkBuffer . Length . Should ( ) . Be ( 2 ) ;
170+ chunkBuffer . Length . Should ( ) . Be ( 0 ) ;
171+ chunkBuffer . Position . Should ( ) . Be ( 0 ) ;
171172 }
172173
173174 [ Fact ]
@@ -188,109 +189,11 @@ public async void ShouldCleanupChunkBufferIfItExceedsMaxChunkBufferSizeAsync()
188189 real . Should ( ) . HaveCount ( ushort . MaxValue ) ;
189190 real . Should ( ) . Contain ( 0 ) ;
190191
191- chunkBuffer . Length . Should ( ) . Be ( 2 ) ;
192+ chunkBuffer . Length . Should ( ) . Be ( 0 ) ;
193+ chunkBuffer . Position . Should ( ) . Be ( 0 ) ;
192194 }
193195
194196 }
195-
196- //public class ReadBSyteMethod
197- //{
198- // [Theory]
199- // [InlineData(new byte[] {0x00, 0x01, 0x80, 0x00, 0x00}, sbyte.MinValue)]
200- // [InlineData(new byte[] {0x00, 0x01, 0x7F, 0x00, 0x00}, sbyte.MaxValue)]
201- // [InlineData(new byte[] {0x00, 0x01, 0x00, 0x00, 0x00}, 0)]
202- // [InlineData(new byte[] {0x00, 0x01, 0xFF, 0x00, 0x00}, -1)]
203- // public void ShouldReturnTheCorrectValue(byte[] response, sbyte correctValue)
204- // {
205- // var chunkedInput = IOExtensions.CreateChunkedPackStreamReaderFromBytes(response);
206- // var actual = chunkedInput.NextSByte();
207- // actual.Should().Be(correctValue); //, $"Got: {actual}, expected: {correctValue}");
208- // }
209- //}
210-
211- //public class MultipleChunksTests
212- //{
213- // private readonly ITestOutputHelper _output;
214-
215- // public MultipleChunksTests(ITestOutputHelper output)
216- // {
217- // _output = output;
218- // }
219-
220- // [Theory]
221- // //-----------------------|---head1--|----|---head2---|-----------|--msg end--|
222- // [InlineData(new byte[] { 0x00, 0x01, 0x00, 0x00, 0x02, 0x01, 0x02, 0x00, 0x00 }, new byte[] { 0x00, 0x01, 0x02})]
223- // public void ShouldReadMessageAcrossChunks(byte[] input, byte[] correctValue)
224- // {
225- // var chunkedInput = IOExtensions.CreateChunkedPackStreamReaderFromBytes(input);
226-
227- // byte[] actual = chunkedInput.ReadBytes(3);
228-
229- // actual.Should().Equal(correctValue);
230- // }
231-
232- // [Theory]
233- // //-----------------------|---head1--|----|---head2---|-----------|--msg end--|
234- // [InlineData(new byte[] { 0x00, 0x01, 0x00, 0x00, 0x02, 0x01, 0x02, 0x00, 0x00 }, new byte[] { 0x00, 0x01, 0x02 })]
235- // public void ShouldLogBytes(byte[] input, byte[] correctValue)
236- // {
237- // var loggerMock = new Mock<ILogger>();
238- // loggerMock.Setup(x => x.Trace(It.IsAny<string>(), It.IsAny<object[]>(), It.IsAny<int>(), It.IsAny<int>()))
239- // .Callback<string, object[]>((s, o) => _output.WriteLine(s + ((byte[])o[0]).ToHexString(showX: true)));
240-
241- // var chunkedInput = IOExtensions.CreateChunkedPackStreamReaderFromBytes(input, loggerMock.Object);
242-
243- // byte[] actual = chunkedInput.ReadBytes(3);
244- // actual.Should().Equal(correctValue);
245- // loggerMock.Verify(x => x.Trace("S: ", It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()), Times.AtLeastOnce);
246- // }
247-
248- // [Theory]
249- // //-----------------------|---head1--|----|---head2---|-----------|--msg end--|
250- // [InlineData(new byte[] { 0x00, 0x01, 0x00, 0x00, 0x02, 0x01, 0x02, 0x00, 0x00 }, new byte[] { 0x00, 0x01, 0x02 })]
251- // public void ShouldReadMessageBiggerThanChunkSize(byte[] input, byte[] correctValue)
252- // {
253- // var chunkedInput = IOExtensions.CreateChunkedPackStreamReaderFromBytes(input);
254-
255- // byte[] actual = chunkedInput.ReadBytes(3);
256- // actual.Should().Equal(correctValue);
257- // }
258- //}
259-
260- //public class ChunkHeaderTests
261- //{
262- // private readonly Random _random = new Random();
263- // public byte Getbyte()
264- // {
265- // var num = _random.Next(0, 26); // 0 to 25
266- // byte letter = (byte)('a' + num);
267- // return letter;
268- // }
269-
270- // [Fact]
271- // public void ShouldReadHeaderWithinUnsignedShortRange()
272- // {
273- // for (var i = 1; i <= UInt16.MaxValue; i = (i << 1) + 1) // i: [0x1, 0xFFFF]
274- // {
275- // ushort chunkHeaderSize = (ushort)(i & 0xFFFF);
276-
277- // var input = new byte[chunkHeaderSize + 2 + 2]; // 0xXX, 0xXX, ..., 0x00, 0x00
278- // input[0] = (byte)((chunkHeaderSize & 0xFF00) >> 8);
279- // input[1] = (byte)(chunkHeaderSize & 0xFF);
280- // for (int j = 2; j < chunkHeaderSize + 2; j++)
281- // {
282- // input[j] = Getbyte();
283- // }
284-
285- // var chunkedInput = IOExtensions.CreateChunkedPackStreamReaderFromBytes(input);
286- // byte[] actual = chunkedInput.ReadBytes(chunkHeaderSize);
287- // for (int j = 0; j < actual.Length; j++)
288- // {
289- // actual[j].Should().Be(input[2 + j]);
290- // }
291- // }
292- // }
293- //}
294-
197+
295198 }
296199}
0 commit comments