CSharpTest.Net
Prompt Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Commands Namespace > CommandInterpreter Class : Prompt Property

Glossary Item Box

Gets/sets the prompt, use "$(OptionName)" to reference options

Syntax

Visual Basic (Declaration) 
Public Property Prompt As String
C# 
public string Prompt {get; set;}

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