Beispiel #1
0
        public void ReadPreviousUnaffectedByPeek()
        {
            var str = "Hello World!";

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str)))
                using (var bs = new BencodeStream(ms))
                {
                    bs.Read(1);
                    Assert.Equal('H', bs.ReadPrevious());
                    Assert.Equal('e', bs.Peek());
                    Assert.Equal('H', bs.ReadPrevious());
                }
        }
Beispiel #2
0
        public void PeekUnnaffectedByReadPrevious()
        {
            var str = "abcdefghijkl";

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str)))
                using (var bs = new BencodeStream(ms))
                {
                    bs.Read(0);
                    Assert.Equal('a', bs.Peek());
                    bs.ReadPrevious();
                    Assert.Equal('a', bs.Peek());

                    bs.Read(1);
                    Assert.Equal('b', bs.Peek());
                    bs.ReadPrevious();
                    Assert.Equal('b', bs.Peek());
                }
        }
Beispiel #3
0
        public void ReadPrevious()
        {
            var str = "Hello World!";

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str)))
                using (var bs = new BencodeStream(ms))
                {
                    Assert.Equal(-1, bs.ReadPrevious());
                    Assert.Equal('H', bs.Read());
                    Assert.Equal('H', bs.ReadPrevious());
                    Assert.Equal('e', bs.Read());
                    Assert.Equal('e', bs.ReadPrevious());

                    bs.Position = 20;

                    Assert.Equal(-1, bs.ReadPrevious());
                }
        }
Beispiel #4
0
        public void ReadPreviousAtStartOfStream()
        {
            var str = "Hello World!";

            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(str)))
                using (var bs = new BencodeStream(ms))
                {
                    Assert.Equal(-1, bs.ReadPrevious());
                }
        }