Starts a command line process with given argument and optional timeout. Supports events or
can be used synchronously with checking Error or Output afterwards. Exceptions are thrown
when things go bad (ExitCode not 0 or process times out).
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Core ProcessRunner
Namespace: DeltaEngine.Core
Assembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The ProcessRunner type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ProcessRunner | Initializes a new instance of the ProcessRunner class |
Methods
Name | Description | |
---|---|---|
Close | ||
SetupStartInfo | ||
Start |
Fields
Name | Description | |
---|---|---|
timeoutInMs |
Properties
Name | Description | |
---|---|---|
ArgumentsLine | ||
Errors | ||
FilePath | ||
IsExitCodeRelevant | ||
IsWaitingForExit | ||
Output | ||
WorkingDirectory |
Events
Name | Description | |
---|---|---|
ErrorOutputEvent | ||
StandardOutputEvent |
Remarks
Examples
[Test] public void DefaultWorkingDirectory() { var processRunner = new ProcessRunner("cmd.exe", "/c dir"); Assert.AreEqual(Environment.CurrentDirectory, processRunner.WorkingDirectory); }
[Test] public void ChangingWorkingDirectory() { var processRunner = new ProcessRunner("cmd.exe", "/c dir"); processRunner.Start(); var outputWithDefaultWorkingDirectory = processRunner.Output; processRunner.WorkingDirectory = @"C:\"; processRunner.Start(); var outputWithDefinedWorkingDirectory = processRunner.Output; Assert.AreNotEqual(outputWithDefaultWorkingDirectory, outputWithDefinedWorkingDirectory); }
[Test] public void StandardOutputEvent() { var logger = new MockLogger(); var processRunner = new ProcessRunner("cmd.exe", "/c dir"); processRunner.StandardOutputEvent += outputMessage => logger.Write(Logger.MessageType.Info, outputMessage); processRunner.Start(); Assert.IsTrue( logger.LastMessage.Contains("Dir(s)") || logger.LastMessage.Contains("Verzeichnis(se)"), logger.LastMessage); }
See Also