console-redirect

C# unit test for a method which calls Console.ReadLine()

僤鯓⒐⒋嵵緔 提交于 2019-12-28 12:31:29
问题 I want to create a unit test for a member function of a class called ScoreBoard which is storing the top five players in a game. The problem is that the method I created a test for ( SignInScoreBoard ) is calling Console.ReadLine() so the user can type their name: public void SignInScoreBoard(int steps) { if (topScored.Count < 5) { Console.Write(ASK_FOR_NAME_MESSAGE); string name = Console.ReadLine(); KeyValuePair<string, int> pair = new KeyValuePair<string, int>(name, steps); topScored

Redirecting Console Output to winforms ListBox

為{幸葍}努か 提交于 2019-12-20 10:55:32
问题 I have built a library that dumps most of its debug text using Console.WriteLine(); I am now I am the process of using the library in a Windows Forms Application, and still need access to the Console output. ( To Display in a List/RichText box ) I Noticed I can override the standard out of the console to a TextWriter, but how would I then get this data into the display . I Tried doing something along the lines of public partial class Form1 : Form { Timer T; MemoryStream mem; StreamWriter

Realtime Console Output Redirection using Process

前提是你 提交于 2019-12-18 14:52:59
问题 I am using VBOXMANAGE to "export" a guest machine. VBOXManage is a Console application that can control the guest machine's behavior from the host. Since the export command is a long process, it returns process updates like so: 0%...10%...20%...30%...100% I am writing a C# application that will invoke VBOXManage using Process. Here's my code: Process VBOXProc = new Process(); VBOXProc.StartInfo.FileName = VBOXMANAGE; VBOXProc.StartInfo.Arguments = Arguments; VBOXProc.StartInfo.UseShellExecute

Realtime Console Output Redirection using Process

拜拜、爱过 提交于 2019-11-30 12:01:10
I am using VBOXMANAGE to "export" a guest machine. VBOXManage is a Console application that can control the guest machine's behavior from the host. Since the export command is a long process, it returns process updates like so: 0%...10%...20%...30%...100% I am writing a C# application that will invoke VBOXManage using Process. Here's my code: Process VBOXProc = new Process(); VBOXProc.StartInfo.FileName = VBOXMANAGE; VBOXProc.StartInfo.Arguments = Arguments; VBOXProc.StartInfo.UseShellExecute = false; VBOXProc.StartInfo.CreateNoWindow = true; VBOXProc.StartInfo.WindowStyle = ProcessWindowStyle

C# unit test for a method which calls Console.ReadLine()

那年仲夏 提交于 2019-11-28 07:42:42
I want to create a unit test for a member function of a class called ScoreBoard which is storing the top five players in a game. The problem is that the method I created a test for ( SignInScoreBoard ) is calling Console.ReadLine() so the user can type their name: public void SignInScoreBoard(int steps) { if (topScored.Count < 5) { Console.Write(ASK_FOR_NAME_MESSAGE); string name = Console.ReadLine(); KeyValuePair<string, int> pair = new KeyValuePair<string, int>(name, steps); topScored.Insert(topScored.Count, pair); } else { if (steps < topScored[4].Value) { topScored.RemoveAt(4); Console