Class FakeOwnedProcess
The toolkit's one fake IOwnedProcess, for an owned server or client: exits when the test says so
(Exit(int)) or when stopped. Launched by a FakeOwnedServer, it records its stops there and follows
that server's switches. Created on its own, for example as the client process of ClientSession.Launch, its own
IgnoreQuit and StopFailure decide how a stop ends.
public sealed class FakeOwnedProcess : IOwnedProcess
- Inheritance
-
objectFakeOwnedProcess
- Implements
Constructors
FakeOwnedProcess(int)
A fake process of its own, with the given PID.
public FakeOwnedProcess(int id = 1)
Parameters
idint
Properties
Disposals
public int Disposals { get; }
Property Value
- int
HasExited
public bool HasExited { get; }
Property Value
- bool
Id
The PID; for a FakeOwnedServer's process, its boot number (1, 2, ...).
public int Id { get; }
Property Value
- int
IgnoreQuit
Asked to quit, it does not exit, so StopCleanly(TimeSpan, TimeSpan) kills it (Killed). A FakeOwnedServer's process follows IgnoreQuit instead.
public bool IgnoreQuit { get; set; }
Property Value
- bool
StopFailure
When set, every stop (even of an exited process) counts, then throws a new exception from it and leaves the process as it was: an unproven stop (an System.IO.IOException) or a refused one (a System.TimeoutException).
public Func<Exception>? StopFailure { get; set; }
Property Value
- Func<Exception>
Stops
How many times Stop(TimeSpan) or StopCleanly(TimeSpan, TimeSpan) was called, failed stops included.
public int Stops { get; }
Property Value
- int
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Exit(int)
public void Exit(int code)
Parameters
codeint
Exited(int, int)
A fake process that has already exited with code, as a client that crashes during startup.
public static FakeOwnedProcess Exited(int code, int id = 1)
Parameters
codeintidint
Returns
Stop(TimeSpan)
Kills the process at once and waits up to timeout for it to exit.
public void Stop(TimeSpan timeout)
Parameters
timeoutTimeSpan
StopCleanly(TimeSpan, TimeSpan)
Records stop{Id} as Stop(TimeSpan) does. Asked to quit, it exits with 0 (Clean), unless
it ignores the request (IgnoreQuit): then it is killed after quit and exits with -1.
public ProcessStop StopCleanly(TimeSpan quit, TimeSpan kill)
Parameters
quitTimeSpankillTimeSpan
Returns
WaitForExitAsync(CancellationToken)
Completes with the exit code when the process exits; startup fails as soon as it does.
public Task<int> WaitForExitAsync(CancellationToken cancellation)
Parameters
cancellationCancellationToken
Returns
- Task<int>