public void ParseFunctions_ReadLine_SetsInputAndCallsNextFunction() { // Arrange // Note that the string being used here has some extra white // space around it. var buffer = Encoding.ASCII.GetBytes(" Lorem ipsum "); var memStream = new MemoryStream(buffer); var reader = new StreamReader(memStream); var state = new object(); var context = new ParseContext(reader, state); var numCallsMadeToNextFunction = 0; Task next() { numCallsMadeToNextFunction++; return(Task.CompletedTask); } // Act ParseFunctions.ReadLine(context, next).Wait(); // Assert // Note that the expected value is a trimmed version of the one // used above to create the buffer variable. Assert.AreEqual("Lorem ipsum", context.Input); Assert.AreEqual(1, numCallsMadeToNextFunction); }
public void ParseFunctions_ReadLine_ThrowsOnNullParseContext() { // Arrange ParseContext nullParseContext = null; Task next() => Task.CompletedTask; // Act ParseFunctions.ReadLine(nullParseContext, next); }
public void ParseFunctions_ReadLine_ThrowsOnNullNextFunction() { // Arrange var reader = new StreamReader(new MemoryStream()); var state = new object(); var context = new ParseContext(reader, state); Func <Task> nullNextFunction = null; // Act ParseFunctions.ReadLine(context, nullNextFunction); }