mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Refactor
This commit is contained in:
@@ -1,33 +1,36 @@
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Attributes;
|
||||
using CliFx.Models;
|
||||
using CliFx.Services;
|
||||
using CliFx.Tests.TestObjects;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace CliFx.Tests
|
||||
{
|
||||
public partial class CliApplicationTests
|
||||
{
|
||||
[DefaultCommand]
|
||||
public class TestCommand : Command
|
||||
{
|
||||
public override ExitCode Execute() => new ExitCode(13);
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class CliApplicationTests
|
||||
public partial class CliApplicationTests
|
||||
{
|
||||
[Test]
|
||||
public async Task RunAsync_Test()
|
||||
{
|
||||
// Arrange
|
||||
var command = new TestCommand();
|
||||
var expectedExitCode = await command.ExecuteAsync();
|
||||
|
||||
var commandOptionParser = new CommandOptionParser();
|
||||
|
||||
var typeProvider = new TypeProvider(typeof(TestCommand));
|
||||
var commandOptionConverter = new CommandOptionConverter();
|
||||
var commandResolver = new CommandResolver(typeProvider, commandOptionConverter);
|
||||
|
||||
var application = new CliApplication(commandOptionParser, commandResolver);
|
||||
var application = new CliApplication(
|
||||
new CommandOptionParser(),
|
||||
new CommandResolver(new[] {typeof(TestCommand)}, new CommandOptionConverter()));
|
||||
|
||||
// Act
|
||||
var exitCodeValue = await application.RunAsync();
|
||||
|
||||
// Assert
|
||||
Assert.That(exitCodeValue, Is.EqualTo(expectedExitCode.Value), "Exit code");
|
||||
Assert.That(exitCodeValue, Is.EqualTo(13), "Exit code");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user