Library/Library.Test/TestAssemblyRunner.cs
C# | Copy Code |
---|---|
using (AssemblyRunner runner = new AssemblyRunner(Exe)) { int exitCode = -1; bool receivedExit = false; ProcessExitedEventHandler handler = delegate(object o, ProcessExitedEventArgs e) { receivedExit = true; exitCode = e.ExitCode; }; runner.ProcessExited += handler; runner.ProcessExited -= handler; Assert.AreEqual(0, runner.Run()); Assert.IsFalse(receivedExit); Assert.AreEqual(-1, exitCode); } |
VB.NET | Copy Code |
---|---|
Using runner As New AssemblyRunner(Exe) Dim exitCode As Integer = -1 Dim receivedExit As Boolean = False Dim handler As ProcessExitedEventHandler = Function(o As Object, e As ProcessExitedEventArgs) Do receivedExit = True exitCode = e.ExitCode End Function runner.ProcessExited += handler runner.ProcessExited -= handler Assert.AreEqual(0, runner.Run()) Assert.IsFalse(receivedExit) Assert.AreEqual(-1, exitCode) End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
AssemblyRunner ClassAssemblyRunner Members
Overload List