public void Processor_RunHidden_CmdWindowDir() { try { //FileVersionInfo fvi = new FileVersionInfo("filename"); HostProcessor host = new HostProcessor(); Processor p = host.CreateProcessor(); p.FileName = "cmd.exe"; p.Arguments = "/C dir /B " + Environment.CurrentDirectory; if (p.RunHidden()) { int exitCode = p.ExitCode; string s = p.Output; string errMsg = p.ErrorOutput; Assert.AreEqual(p.ExitCode, 0); Assert.IsFalse(p.DidTimeout); Assert.IsNotNull(p.Output); Assert.IsFalse(p.DidTimeout); Assert.IsFalse(p.IsRunning); //Assert.IsTrue(p.IsStarted); } else { Assert.Fail(p.LastError); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Processor_RunCurlGetWebPage() { try { HostProcessor host = new HostProcessor(); Processor p = host.CreateProcessor(); //p. p.FileName = "c:\\bin\\curl.exe"; //p.Arguments = "http://example.com"; p.Arguments = "http://labobjects.com"; if (p.RunHidden()) { int exitCode = p.ExitCode; string s = p.Output; string errMsg = p.ErrorOutput; Assert.AreEqual(p.ExitCode, 0); Assert.IsNotNull(p.Output); Assert.IsFalse(p.DidTimeout); Assert.IsFalse(p.IsRunning); //Assert.IsTrue(p.IsStarted); } else { Assert.Fail(p.LastError); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Processor_RunHidden_ChoiceNo() { try { //FileVersionInfo fvi = new FileVersionInfo("filename"); HostProcessor host = new HostProcessor(); Processor p = host.CreateProcessor(); p.FileName = "cmd.exe"; p.Arguments = "/C choice"; if (p.RunHidden("N")) { int exitCode = p.ExitCode; string s = p.Output; string errMsg = p.ErrorOutput; Assert.AreEqual(p.ExitCode, 2); Assert.IsFalse(p.DidTimeout); Assert.IsNotNull(p.Output); Assert.IsFalse(p.IsRunning); Assert.AreEqual("No Error", p.LastError); } else { Assert.Fail(p.LastError); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void Test_CMDWindow() { //todo: wait for exit methid // input stream flush (or otehr helpers? // close HostProcessor host = new HostProcessor(); Processor processor = host.CreateProcessor(); processor.FileName = "cmd.exe"; processor.RedirectStandardError = true; processor.RedirectStandardOutput = true; processor.RedirectStandardInput = true; processor.WindowStyle = ProcessWindowStyle.Hidden; processor.Start(); processor.InputWriteLine("cd c:\\code"); processor.InputWriteLine("dir /b *.*"); if (processor.IsOutputAvailable) { string so = processor.OutputRead(); } if (processor.IsErrorAvailable) { string se = processor.ErrorOutputRead(); } processor.InputWriteLine("exit"); while (!processor.HasExited) { } processor.Close(); if (host.HasActiveProcessors) { } }