예제 #1
0
        public void AccessBackingBytes_should_adjust_count()
        {
            var bytes = new byte[4];
            var buffer = new ByteArrayBuffer(bytes, isReadOnly: true);
            var subject = new ByteBufferSlice(buffer, 1, 2);

            var result = subject.AccessBackingBytes(0);

            result.Count.Should().Be(2); // not 3
        }
예제 #2
0
        public void AccessBackingBytes_should_adjust_count_when_multiple_chunks_are_present()
        {
            var arrays = new[] { new byte[] { 1, 2 }, new byte[] { 3, 4 } };
            var chunks = arrays.Select(a => new ByteArrayChunk(a));
            var buffer = new MultiChunkBuffer(chunks, isReadOnly: true);
            var subject = new ByteBufferSlice(buffer, 1, 2);

            var result = subject.AccessBackingBytes(0);

            result.Array.Should().BeSameAs(arrays[0]);
            result.Offset.Should().Be(1);
            result.Count.Should().Be(1); // not 2 or 3
        }
예제 #3
0
 public Reflector(ByteBufferSlice instance)
 {
     _instance = instance;
 }
예제 #4
0
        public void constructor_should_initialize_subject()
        {
            var buffer = new ByteArrayBuffer(new byte[3], isReadOnly: true);

            var subject = new ByteBufferSlice(buffer, 1, 2);

            var reflector = new Reflector(subject);
            subject.Buffer.Should().BeSameAs(buffer);
            reflector._disposed.Should().BeFalse();
            reflector._offset.Should().Be(1);
            reflector._length.Should().Be(2);
        }