CSharpTest.Net
ReadNextCharacter Delegate
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace : ReadNextCharacter Delegate

Glossary Item Box

Used for obtaining input directly from user rather than from the std:in stream

Syntax

Visual Basic (Declaration) 
Public Delegate Function ReadNextCharacter() As Char
C# 
public delegate char ReadNextCharacter()

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.NETCopy 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

Generated with Document! X 2011 by Innovasys