-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IHostApplicationLifetime for testing
- Loading branch information
1 parent
e51d3c5
commit 408460a
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace Stateflows.Testing | ||
{ | ||
internal class TestingHost : IHostApplicationLifetime | ||
{ | ||
private readonly CancellationTokenSource ApplicationStartedToken = new CancellationTokenSource(); | ||
public CancellationToken ApplicationStarted => ApplicationStartedToken.Token; | ||
|
||
private readonly CancellationTokenSource ApplicationStoppingToken = new CancellationTokenSource(); | ||
public CancellationToken ApplicationStopping => ApplicationStoppingToken.Token; | ||
|
||
private readonly CancellationTokenSource ApplicationStoppedToken = new CancellationTokenSource(); | ||
public CancellationToken ApplicationStopped => ApplicationStoppedToken.Token; | ||
|
||
public void StartApplication() | ||
{ | ||
ApplicationStartedToken.Cancel(); | ||
} | ||
|
||
public void StopApplication() | ||
{ | ||
ApplicationStoppingToken.Cancel(); | ||
ApplicationStoppedToken.Cancel(); | ||
} | ||
} | ||
} |