CSharpTest.Net
Run(TextReader) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class > Run Method : Run(TextReader) Method

input

Glossary Item Box

Runs each line from the reader until EOF, can be used with Console.In

Syntax

Visual Basic (Declaration) 
Public Overloads Sub Run( _
   ByVal input As TextReader _
) 
C# 
public void Run( 
   TextReader input
)

Parameters

input

Example

Library/Library.Test/TestCmdInterpreter.cs

C#Copy Code
TextWriter stdout = Console.Out, stderr = Console.Error;
try
{
    StringWriter sw = new StringWriter();
    Console.SetError(sw);
    Console.SetOut(sw);

    string result;
    CommandInterpreter ci = new CommandInterpreter(new TestCommands());

    ci.Prompt = "$(MissingProperty)";
    ci.Run(new StringReader("EXIT"));
    result = sw.ToString();
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"));
    ci.Prompt = String.Empty;

    sw.GetStringBuilder().Length = 0;//clear
    ci.Run(new ErrorReader());

    result = sw.ToString();
    Assert.IsTrue(result.StartsWith(typeof(NotImplementedException).FullName));
}
finally
{
    Console.SetOut(stdout);
    Console.SetError(stderr);
}
VB.NETCopy Code
Dim stdout As TextWriter = Console.Out, stderr As TextWriter = Console.[Error]
Try
    Dim sw As New StringWriter()
    Console.SetError(sw)
    Console.SetOut(sw)

    Dim result As String
    Dim ci As New CommandInterpreter(New TestCommands())

    ci.Prompt = "$(MissingProperty)"
    ci.Run(New StringReader("EXIT"))
    result = sw.ToString()
    Assert.IsTrue(result.StartsWith("Unknown option specified: MissingProperty"))
    ci.Prompt = [String].Empty

    sw.GetStringBuilder().Length = 0
    'clear
    ci.Run(New ErrorReader())

    result = sw.ToString()
    Assert.IsTrue(result.StartsWith(GetType(NotImplementedException).FullName))
Finally
    Console.SetOut(stdout)
    Console.SetError(stderr)
End Try

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys