Beispiel #1
0
        public void AvailableBufferReturnsAreaThatIsUnused()
        {
            // Arrange
            var baton = new Baton { Buffer = "xxhello worldxx".ToArraySegment() };
            baton.Buffer = new ArraySegment<byte>(baton.Buffer.Array, 2, 5);

            // Act
            var buffer = baton.Available(0);

            // Assert
            Assert.Equal(8, buffer.Count);
            Assert.Equal(" worldxx", buffer.ToString(Encoding.Default));
        }
Beispiel #2
0
        public void AvailableBufferBringsOffsetBackToZeroIfOccupiedSegmentIsZeroLength()
        {
            // Arrange
            var baton = new Baton { Buffer = "xxhello worldxx".ToArraySegment() };
            baton.Buffer = new ArraySegment<byte>(baton.Buffer.Array, 2, 0);

            // Act
            var buffer = baton.Available(0);

            // Assert
            Assert.Equal(15, buffer.Count);
            Assert.Equal("xxhello worldxx", buffer.ToString(Encoding.Default));
        }