FakeProcess Class

Represents an in-memory process handle intended for tests.

public sealed class FakeProcess : IProcessHandle, IDisposable
Implements

Properties

NameDescription
Meziantou.Framework.IProcessHandle.ErrorStream
Meziantou.Framework.IProcessHandle.ExitCode
Meziantou.Framework.IProcessHandle.HasExited
Meziantou.Framework.IProcessHandle.Id
Meziantou.Framework.IProcessHandle.InputStream
Meziantou.Framework.IProcessHandle.OutputStream
Meziantou.Framework.IProcessHandle.SafeProcessHandle

Meziantou.Framework.IProcessHandle.ErrorStream

FakeProcess.cs
Stream IProcessHandle.ErrorStream { get; }

Property value

Stream

No documentation is available.

Meziantou.Framework.IProcessHandle.ExitCode

FakeProcess.cs
int IProcessHandle.ExitCode { get; }

Property value

int

No documentation is available.

Meziantou.Framework.IProcessHandle.HasExited

FakeProcess.cs
bool IProcessHandle.HasExited { get; }

Property value

bool

No documentation is available.

Meziantou.Framework.IProcessHandle.Id

FakeProcess.cs
int IProcessHandle.Id { get; }

Property value

int

No documentation is available.

Meziantou.Framework.IProcessHandle.InputStream

FakeProcess.cs
Stream IProcessHandle.InputStream { get; }

Property value

Stream

No documentation is available.

Meziantou.Framework.IProcessHandle.OutputStream

FakeProcess.cs
Stream IProcessHandle.OutputStream { get; }

Property value

Stream

No documentation is available.

Meziantou.Framework.IProcessHandle.SafeProcessHandle

FakeProcess.cs
SafeProcessHandle? IProcessHandle.SafeProcessHandle { get; }

Property value

SafeProcessHandle?

No documentation is available.

Methods

NameDescription
Complete(int?)Completes the process execution and sets the process exit code.
Create(int)Creates a fake process with empty standard output and standard error streams.
Create(int, Stream, Stream)Creates a fake process with the specified standard output and standard error streams.
Create(int, string, string)Creates a fake process with UTF-8 encoded text output.
CreatePending(int)Creates a fake process that does not complete automatically when started.
CreatePending(int, Stream, Stream)Creates a fake process with provided streams that does not complete automatically when started.
CreatePending(int, string, string)Creates a fake process with text output that does not complete automatically when started.
Meziantou.Framework.IProcessHandle.Kill(bool)
Meziantou.Framework.IProcessHandle.Start()
Meziantou.Framework.IProcessHandle.WaitForExitAsync(CancellationToken)
ReadInputAsText(Encoding?)Reads the captured standard input text as UTF-8 by default.
System.IDisposable.Dispose()

Complete(int?)

FakeProcess.cs

Completes the process execution and sets the process exit code.

public void Complete(int? exitCode = null)

Parameters

exitCode int?
Optional exit code override. If null, keeps the configured code.

Create overloads

Create(int)

FakeProcess.cs

Creates a fake process with empty standard output and standard error streams.

public static FakeProcess Create(int exitCode)
Parameters
exitCode int
The process exit code.
Returns

FakeProcess

Create(int, Stream, Stream)

FakeProcess.cs

Creates a fake process with the specified standard output and standard error streams.

public static FakeProcess Create(int exitCode, Stream outputStream, Stream errorStream)
Parameters
exitCode int
The process exit code.
outputStream Stream
The stream used as standard output.
errorStream Stream
The stream used as standard error.
Returns

FakeProcess

Create(int, string, string)

FakeProcess.cs

Creates a fake process with UTF-8 encoded text output.

public static FakeProcess Create(int exitCode, string outputText, string errorText)
Parameters
exitCode int
The process exit code.
outputText string
The standard output text.
errorText string
The standard error text.
Returns

FakeProcess

CreatePending overloads

CreatePending(int)

FakeProcess.cs

Creates a fake process that does not complete automatically when started.

public static FakeProcess CreatePending(int exitCode)
Parameters
exitCode int
The process exit code.
Returns

FakeProcess

CreatePending(int, Stream, Stream)

FakeProcess.cs

Creates a fake process with provided streams that does not complete automatically when started.

public static FakeProcess CreatePending(int exitCode, Stream outputStream, Stream errorStream)
Parameters
exitCode int
The process exit code.
outputStream Stream
The stream used as standard output.
errorStream Stream
The stream used as standard error.
Returns

FakeProcess

CreatePending(int, string, string)

FakeProcess.cs

Creates a fake process with text output that does not complete automatically when started.

public static FakeProcess CreatePending(int exitCode, string outputText, string errorText)
Parameters
exitCode int
The process exit code.
outputText string
The standard output text.
errorText string
The standard error text.
Returns

FakeProcess

Meziantou.Framework.IProcessHandle.Kill(bool)

FakeProcess.cs
void IProcessHandle.Kill(bool entireProcessTree)

Parameters

entireProcessTree bool

No documentation is available.

Meziantou.Framework.IProcessHandle.Start()

FakeProcess.cs

Returns

bool

No documentation is available.

Meziantou.Framework.IProcessHandle.WaitForExitAsync(CancellationToken)

FakeProcess.cs
Task IProcessHandle.WaitForExitAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Returns

Task

No documentation is available.

ReadInputAsText(Encoding?)

FakeProcess.cs

Reads the captured standard input text as UTF-8 by default.

public string ReadInputAsText(Encoding? encoding = null)

Parameters

encoding Encoding?
The text encoding.

Returns

string The captured standard input content.

System.IDisposable.Dispose()

FakeProcess.cs
void IDisposable.Dispose()

No documentation is available.