This commit is contained in:
Alexey Golub
2019-07-17 22:49:46 +03:00
parent 3611aa51e6
commit 4ba9413012
13 changed files with 88 additions and 158 deletions

View File

@@ -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");
}
}
}