public void TestClosingStreamsUndefinedDoesNotThrow() { Process p = CreateProcessPortable(RemotelyInvokable.WriteLinesAfterClose); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.Start(); p.Close(); RemotelyInvokable.FireClosedEvent(); }
public void TestClosingStreamsAsyncDoesNotThrow() { Process p = CreateProcessPortable(RemotelyInvokable.WriteLinesAfterClose); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; // On netfx, the handler is called once with the Data as null, even if the process writes nothing to the pipe. // That behavior is documented here https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.datareceivedeventhandler p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); p.Close(); RemotelyInvokable.FireClosedEvent(); }
public void TestClosingSyncModeDoesNotCloseStreams() { Process p = CreateProcessPortable(RemotelyInvokable.WriteLinesAfterClose); p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.Start(); var output = p.StandardOutput; var error = p.StandardError; p.Close(); RemotelyInvokable.FireClosedEvent(); output.ReadToEnd(); error.ReadToEnd(); }