-
Notifications
You must be signed in to change notification settings - Fork 0
Console Command
David Yates edited this page Aug 5, 2020
·
2 revisions
This is an injectable service that wraps Console so that you can more easily Unit test your menu items. I use it mainly for testing Prompt Helper; however, you can use it with your own menus if you wish to test them.
Here is the interface with descriptions for each method:
/// <summary>A wrapper around console commands.</summary>
public interface IConsoleCommand
{
/// <summary>Clears the screen</summary>
void Clear();
/// <summary>Obtains then next key that is pressed.</summary>
ConsoleKeyInfo ReadKey();
/// <summary>Reads a line using the Console's ReadLine method.</summary>
string ReadLine();
/// <summary>Writes text using the Console's Write method</summary>
/// <param name="line">Text to write</param>
void Write(string line);
/// <summary>Writes text using the Console's WriteLine method</summary>
/// <param name="line">Text to write</param>
void WriteLine(string line);
}