Пример #1
0
        public void SeekCharacter()
        {
            // 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);

            // Execute
            reader.SeekCharacter(17);

            // Assert
            Assert.AreEqual(17, reader.CharacterPosition);
            Assert.AreEqual($"a test,{NL}a test!{NL}Doo dee doo.", reader.ReadToEnd());
        }
Пример #2
0
        public void SeekCharacterWithUtf8()
        {
            // Setup
            var text   = $"ƒun ‼Æ¢ with åò☺ encoding!{NL}ƒun ‼Æ¢ with åò☺ encoding!{NL}ƒun ‼Æ¢ with åò☺ encoding!{NL}Ha!";
            var bytes  = Encoding.UTF8.GetBytes(text);
            var stream = new MemoryStream(bytes);
            var reader = new AdvancedStreamReader(stream);

            // Pre-condition assert
            Assert.IsTrue(bytes.Length > text.Length); // More bytes than characters in sample text.

            // Execute
            reader.SeekCharacter(84);

            // Assert
            Assert.AreEqual(84, reader.CharacterPosition);
            Assert.AreEqual($"Ha!", reader.ReadToEnd());
        }