public void TestExecute() { using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION); wrapper.Execute(); Assert.True(wrapper.Executing); Assert.Throws <InvalidOperationException>(() => wrapper.Execute()); wrapper.Kill(); }
public void TestKill() { using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION); wrapper.Execute(); wrapper.Kill(); Assert.False(wrapper.Executing); }
public static void Main() { CWrapper wrapper = new CWrapper("cmd"); wrapper.OutputDataReceived += (s, e) => Console.WriteLine(e.Data); wrapper.Execute("/C ping www.google.co.nz"); wrapper.ExitedMRE.Wait(); }
public void TestExitEvent() { using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION); DateTime exitTime = DateTime.MinValue; wrapper.Exited += (_, e) => exitTime = e; wrapper.Execute(EchoConsole.Program.EXIT_KEY); wrapper.ExitedMRE.Wait(); Assert.True(exitTime.AddMilliseconds(10) > DateTime.Now); }
public void TestKillEventFired() { using CWrapper wrapper = new CWrapper(Constants.ECHO_CONSOLE_LOCATION); bool eventFired = false; wrapper.Killed += (_, __) => eventFired = true; wrapper.Execute(); wrapper.Kill(); wrapper.KilledMRE.Wait(); Assert.True(eventFired); }
public void TestOutput() { using CWrapper wrapper = GetWrapper(); string returnData = null; wrapper.OutputDataReceived += (_, e) => returnData = e.Data; wrapper.Execute(EchoConsole.Program.FLOOD_KEY); wrapper.OutputDataMRE.Wait(); wrapper.Kill(); Assert.Equal(EchoConsole.Program.FLOOD_OUTPUT, returnData); }
public void TestInput() { const string ECHO_DATA = "This data shall be echoed"; string returnData = null; using CWrapper wrapper = GetWrapper(); wrapper.OutputDataReceived += (_, e) => returnData = e.Data; wrapper.Execute(); wrapper.WriteToConsole(ECHO_DATA); wrapper.OutputDataMRE.Wait(); wrapper.Kill(); Assert.Equal(ECHO_DATA, returnData); }