CSharpTest.Net
Run() Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > AssemblyRunner Class > Run Method : Run() Method

Glossary Item Box

Runs the process and returns the exit code.

Syntax

Visual Basic (Declaration) 
Public Overloads Function Run() As Integer
C# 
public int Run()

Example

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.NETCopy 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

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys