public void Peek_Case1(string prefixText, string readerText, int firstChar, int secondChar) { // Arrange var r = new PrependableReader(CharPosition.BeginningOfFile, prefixText.ToArray(), new StringReader(readerText)); // Act var ch0 = r.Peek(); r.Read(); var ch1 = r.Peek(); // Assert Assert.That(ch0, Is.EqualTo(firstChar)); Assert.That(ch1, Is.EqualTo(secondChar)); }
public void Reattach_Case1(string prefixText, string readerText) { // Arrange var r = new PrependableReader(CharPosition.BeginningOfFile, prefixText.ToArray(), new StringReader(readerText)); r.Read(); // Act r.Reattach(CharPosition.BeginningOfFile, prefixText.ToArray()); var p = r.Position.Index; var l = r.Position.Line; var c = r.Position.Column; var ch = r.Peek(); // Assert Assert.That(p, Is.EqualTo(0)); Assert.That(l, Is.EqualTo(1)); Assert.That(c, Is.EqualTo(1)); Assert.That(ch, Is.EqualTo(prefixText.Length == 0 ? readerText[1] : (prefixText + readerText)[0])); }
public void Reattach_Case2(string prefixText, string readerText) { // Arrange var r = new PrependableReader(CharPosition.BeginningOfFile, prefixText.ToArray(), new StringReader(readerText)); r.Read(); r.Read(); r.Read(); // Act r.Reattach(CharPosition.BeginningOfFile.NextColumn, "ab".ToArray()); var p = r.Position.Index; var l = r.Position.Line; var c = r.Position.Column; var ch = r.Peek(); // Assert Assert.That(p, Is.EqualTo(1)); Assert.That(l, Is.EqualTo(1)); Assert.That(c, Is.EqualTo(2)); Assert.That(ch, Is.EqualTo('a')); Assert.That(r.ReadToEnd(), Is.EqualTo("ab3456789")); }