public void ContentAppendedToTemporaryBufferIsCopiedToPreviousBufferWhenAccepted() { // Arrange ParserContext context = SetupTestRun("barbazbiz", b => b.Read()); context.ContentBuffer.Append("foo"); // Act using (context.StartTemporaryBuffer()) { context.ContentBuffer.Append("bar"); using (context.StartTemporaryBuffer()) { context.ContentBuffer.Append("baz"); context.AcceptTemporaryBuffer(); } context.AcceptTemporaryBuffer(); Assert.IsFalse(context.InTemporaryBuffer); Assert.AreEqual("foobarbaz", context.ContentBuffer.ToString()); } }
public void ContentFromAcceptedTemporaryBufferIsNotAffectedByDisposalOfTheTemporaryBuffer() { // Arrange ParserContext context = SetupTestRun("barbazbiz", b => b.Read()); context.ContentBuffer.Append("foo"); // Act using (context.StartTemporaryBuffer()) { context.ContentBuffer.Append("bar"); context.AcceptTemporaryBuffer(); } Assert.AreEqual("foobar", context.ContentBuffer.ToString()); }
public void CallingAcceptTemporaryBufferCausesEndOfLookaheadWithNoBacktrack() { // Arrange ParserContext context = SetupTestRun("barbazbiz", r => r.Read()); // Act using (context.StartTemporaryBuffer()) { context.Source.Read(); context.Source.Read(); context.AcceptTemporaryBuffer(); } // Assert Assert.AreEqual('b', context.CurrentCharacter); }
public void ContentAppendedToTemporaryBufferIsLostWhenRejectedByExplicitMethod() { // Arrange ParserContext context = SetupTestRun("barbazbiz", b => b.Read()); context.ContentBuffer.Append("foo"); // Act using (context.StartTemporaryBuffer()) { context.ContentBuffer.Append("bar"); using (context.StartTemporaryBuffer()) { context.ContentBuffer.Append("baz"); context.RejectTemporaryBuffer(); } context.AcceptTemporaryBuffer(); Assert.IsFalse(context.InTemporaryBuffer); Assert.AreEqual("foobar", context.ContentBuffer.ToString()); } }