Added StandardOutput property to IProcess

Improved IProcess, ProcessWrap and unit tests.
This commit is contained in:
Severin Friede 2015-09-28 17:52:52 +02:00
Родитель 887426a468
Коммит 9bb72ab955
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Diagnostics;
using SystemInterface.IO;
namespace SystemInterface.Diagnostics
{
@ -62,6 +63,16 @@ namespace SystemInterface.Diagnostics
/// <returns>true if the associated process has reached an idle state.</returns>
bool WaitForInputIdle();
/// <summary>
/// Gets a stream used to read the output of the application.
/// </summary>
/// <value>
/// A <see cref="IStreamReader"/> implementation that can be used
/// to read the standard output stream of the application.
/// </value>
[MonitoringDescription("ProcessStandardOutput"), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
IStreamReader StandardOutput { get; }
/*
// Events

Просмотреть файл

@ -30,5 +30,17 @@ namespace SystemWrapper.Tests.IO
Assert.AreNotSame(origInfo, instance.ProcessInstance);
Assert.IsNotNull(instance.ProcessInstance);
}
[Test]
[ExpectedException(typeof(System.InvalidOperationException))]
public void StandardOutput_NotNull_ThrowsExceptionBecauseProcessNotYetStarted()
{
var instance = new ProcessWrap();
var origInfo = instance.ProcessInstance;
instance.Initialize();
Assert.AreNotSame(origInfo, instance.ProcessInstance);
Assert.IsNotNull(instance.ProcessInstance);
Assert.IsNotNull(instance.StandardOutput);
}
}
}

Просмотреть файл

@ -1,5 +1,7 @@
using System;
using System.Diagnostics;
using SystemInterface.Diagnostics;
using SystemInterface.IO;
namespace SystemWrapper.Diagnostics
{
@ -58,6 +60,15 @@ namespace SystemWrapper.Diagnostics
set { this._startInfo = value; }
}
/// <inheritdoc />
public IStreamReader StandardOutput
{
get
{
return new IO.StreamReaderWrap(ProcessInstance.StandardOutput);
}
}
/// <inheritdoc />
public void WaitForExit()
{