Library/Library.Test/TestProcessRunner.cs
C# | Copy Code |
---|---|
using (TempDirectory dir = new TempDirectory()) using (ProcessRunner runner = new ProcessRunner("cmd.exe", "/C", "echo CD")) { List<string> lines = new List<string>(); runner.OutputReceived += delegate(Object o, ProcessOutputEventArgs e) { lines.Add(e.Data); }; Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory); runner.WorkingDirectory = dir.TempPath; Assert.AreEqual(dir.TempPath, runner.WorkingDirectory); int exitCode = runner.Run(); Assert.AreEqual(0, exitCode); Assert.AreEqual(dir.TempPath.TrimEnd('\\', '/'), lines[0].TrimEnd('\\', '/')); } |
VB.NET | Copy Code |
---|---|
Using dir As New TempDirectory() Using runner As New ProcessRunner("cmd.exe", "/C", "echo CD") Dim lines As New List(Of String)() runner.OutputReceived += Function(o As [Object], e As ProcessOutputEventArgs) Do lines.Add(e.Data) End Function Assert.AreNotEqual(dir.TempPath, runner.WorkingDirectory) runner.WorkingDirectory = dir.TempPath Assert.AreEqual(dir.TempPath, runner.WorkingDirectory) Dim exitCode As Integer = runner.Run() Assert.AreEqual(0, exitCode) Assert.AreEqual(dir.TempPath.TrimEnd("\"C, "/"C), lines(0).TrimEnd("\"C, "/"C)) End Using End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
ProcessRunner ClassProcessRunner Members
Overload List