Esempio n. 1
0
        public void CanUseOwnedBufferBasedReadableBuffers()
        {
            var data   = Encoding.ASCII.GetBytes("***abc|def|ghijk****"); // note sthe padding here - verifying that it is omitted correctly
            var buffer = new ReadOnlyBuffer <byte>(data, 3, data.Length - 7);

            Assert.Equal(13, buffer.Length);
            var split = buffer.Split((byte)'|');

            Assert.Equal(3, split.Count());
            using (var iter = split.GetEnumerator())
            {
                Assert.True(iter.MoveNext());
                var current = iter.Current;
                Assert.Equal("abc", current.GetAsciiString());

                Assert.True(iter.MoveNext());
                current = iter.Current;
                Assert.Equal("def", current.GetAsciiString());

                Assert.True(iter.MoveNext());
                current = iter.Current;
                Assert.Equal("ghijk", current.GetAsciiString());

                Assert.False(iter.MoveNext());
            }
        }