mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Get rid of internal tests
Move all tests to e2e+ level
This commit is contained in:
31
CliFx.Tests/Commands/CancellableCommand.cs
Normal file
31
CliFx.Tests/Commands/CancellableCommand.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Attributes;
|
||||
|
||||
namespace CliFx.Tests.Commands
|
||||
{
|
||||
[Command("cmd")]
|
||||
public class CancellableCommand : ICommand
|
||||
{
|
||||
public const string CompletionOutputText = "Finished";
|
||||
public const string CancellationOutputText = "Canceled";
|
||||
|
||||
public async ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
try
|
||||
{
|
||||
await Task.Delay(
|
||||
TimeSpan.FromSeconds(3),
|
||||
console.GetCancellationToken()
|
||||
);
|
||||
|
||||
console.Output.WriteLine(CompletionOutputText);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
console.Output.WriteLine(CancellationOutputText);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user