Пример #1
0
        public void Read()
        {
            // Setup
            var bytes = Encoding.UTF8.GetBytes($"This is a test,{NL}a test,{NL}a test!{NL}Doo dee doo.");
            var stream = new MemoryStream(bytes);
            var reader = new AdvancedStreamReader(stream);
            reader.SeekCharacter(15);

            // Execute
            var result = (char)reader.Read();

            // Assert
            Assert.AreEqual(Environment.NewLine[0], result);
            Assert.AreEqual(16, reader.CharacterPosition);
        }
Пример #2
0
        public void ReadToBuffer()
        {
            // Setup
            var bytes = Encoding.UTF8.GetBytes($"This is a test,{NL}a test,{NL}a test!{NL}Doo dee doo.");
            var stream = new MemoryStream(bytes);
            var reader = new AdvancedStreamReader(stream);
            reader.SeekCharacter(15);

            // Execute
            var buffer = new char[15];
            var result = reader.Read(buffer, 0, 15);

            // Assert
            Assert.AreEqual($"{NL}a test,{NL}a te", new string(buffer));
            Assert.AreEqual(15, result);
            Assert.AreEqual(30, reader.CharacterPosition);
        }