Reads a keystroke, not from the std:in stream, rather from the console or ui.
Syntax
Example
Library/Library.Test/TestCmdInterpreter.cs
C# | Copy Code |
---|
string result;
CommandInterpreter ci = new CommandInterpreter(
DefaultCommands.More | DefaultCommands.PipeCommands,
new TestCommands());
//replace the keystroke wait
ci.ReadNextCharacter = GetSpace;
string input = String.Format("Count {0} | MORE", (int)(WindowHeight * 1.5));
result = Capture(ci, input);
StringReader sr = new StringReader(result);
int moreFound = 0;
int index = 0;
string line;
while( null != (line = sr.ReadLine()))
{
if( line == "-- More --" )
moreFound++;
else
Assert.AreEqual((++index).ToString(), line);
}
Assert.AreEqual(1, moreFound); |
VB.NET | Copy Code |
---|
Dim result As String
Dim ci As New CommandInterpreter(DefaultCommands.More Or DefaultCommands.PipeCommands, New TestCommands())
'replace the keystroke wait
ci.ReadNextCharacter = GetSpace
Dim input As String = [String].Format("Count {0} | MORE", DirectCast((WindowHeight * 1.5), Integer))
result = Capture(ci, input)
Dim sr As New StringReader(result)
Dim moreFound As Integer = 0
Dim index As Integer = 0
Dim line As String
While Nothing <> (line = sr.ReadLine())
If line = "-- More --" Then
System.Math.Max(System.Threading.Interlocked.Increment(moreFound),moreFound - 1)
Else
Assert.AreEqual((System.Threading.Interlocked.Increment(index)).ToString(), line)
End If
End While
Assert.AreEqual(1, moreFound) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also