CSharpTest.Net
OutputReceived Event
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Processes Namespace > ProcessRunner Class : OutputReceived Event

Glossary Item Box

Notifies caller of writes to the std::err or std::out

Syntax

Visual Basic (Declaration) 
Public Event OutputReceived As ProcessOutputEventHandler
C# 
public event ProcessOutputEventHandler OutputReceived

Event Data

The event handler receives an argument of type ProcessOutputEventArgs containing data related to this event. The following ProcessOutputEventArgs properties provide information specific to this event.

PropertyDescription
Data Returns the line of text written to standard out/error
Error Returns true if the line of text was written to std::error

Example

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

Requirements

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

See Also

Reference

ProcessRunner Class
ProcessRunner Members

Used By

TestResXtoMc.TestBuildMcFromResX()

Source Code

Library/Processes/ProcessRunner.cs

Generated with Document! X 2011 by Innovasys