public void TestGetBufferStateAPI() { TestSetup(KeyMode.Cmd); Test("echo", Keys( "echo", CheckThat(() => { string input; int cursor; PSConsoleReadLine.GetBufferState(out input, out cursor); Assert.AreEqual("echo", input); Assert.AreEqual(4, cursor); Ast ast; Token[] tokens; ParseError[] parseErrors; PSConsoleReadLine.GetBufferState(out ast, out tokens, out parseErrors, out cursor); Assert.IsNotNull(ast); Assert.IsTrue(ast is ScriptBlockAst && ((ScriptBlockAst)ast).EndBlock.Statements.Count == 1); Assert.IsTrue((tokens[0].TokenFlags & TokenFlags.CommandName) == TokenFlags.CommandName); Assert.AreEqual(0, parseErrors.Length); Assert.AreEqual(4, cursor); }))); }
private void AssertLineIs(string expected) { string input; int unused; PSConsoleReadLine.GetBufferState(out input, out unused); Assert.AreEqual(expected, input); }