public void ParsingTextReaderBlockingComplexReadBlock3() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader, 2); char[] cs = new char[10]; int start = 0; while (!reader.EndOfStream) { int read = reader.ReadBlock(cs, 0, cs.Length); Assert.IsTrue(read <= 10); if (read == 0) { break; } String s = new string(cs, 0, read); Assert.AreEqual(TestData.Substring(start, read), s); start += 10; } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }
public void ParsingBlockingTextReaderSimpleReadBlock() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader); char[] cs = new char[100]; int read = reader.ReadBlock(cs, 0, cs.Length); Assert.AreEqual(TestData.Length, read); Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); String s = new string(cs, 0, read); Assert.AreEqual(TestData, s); }
public void ParsingTextReaderBlockingSimpleReadBlock() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = ParsingTextReader.CreateBlocking(strReader); char[] cs = new char[100]; int read = reader.ReadBlock(cs, 0, cs.Length); Assert.AreEqual(TestData.Length, read); Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); String s = new string(cs, 0, read); Assert.AreEqual(TestData, s); }
public void ParsingBlockingTextReaderComplexReadBlock3() { StringReader strReader = new StringReader(TestData); BlockingTextReader reader = new BlockingTextReader(strReader, 2); char[] cs = new char[10]; int start = 0; while (!reader.EndOfStream) { int read = reader.ReadBlock(cs, 0, cs.Length); Assert.IsTrue(read <= 10); if (read == 0) break; String s = new string(cs, 0, read); Assert.AreEqual(TestData.Substring(start, read), s); start += 10; } Assert.IsTrue(reader.EndOfStream); Assert.AreEqual(-1, reader.Peek()); Assert.AreEqual(-1, reader.Read()); reader.Close(); }