Пример #1
0
        public void TestClosingStreamsUndefinedDoesNotThrow()
        {
            Process p = CreateProcessPortable(RemotelyInvokable.WriteLinesAfterClose);

            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError  = true;

            p.Start();
            p.Close();
            RemotelyInvokable.FireClosedEvent();
        }
Пример #2
0
        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();
        }
Пример #3
0
        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();
        }