Add smoke tests for CliApplicationBuilder

This commit is contained in:
Alexey Golub
2019-08-24 18:31:17 +03:00
parent 0662f341e6
commit b70b25076e
2 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
using System.Threading.Tasks;
using CliFx.Attributes;
using CliFx.Services;
namespace CliFx.Tests
{
public partial class CliApplicationBuilderTests
{
[Command]
private class TestCommand : ICommand
{
public Task ExecuteAsync(IConsole console) => Task.CompletedTask;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.IO;
using CliFx.Services;
using NUnit.Framework;
namespace CliFx.Tests
{
[TestFixture]
public partial class CliApplicationBuilderTests
{
[Test]
public void Build_Smoke_Test()
{
// Just test that application can be built after calling all methods
// Arrange
var builder = new CliApplicationBuilder();
// Act
builder
.AddCommand(typeof(TestCommand))
.AddCommandsFrom(typeof(TestCommand).Assembly)
.AddCommands(new[] {typeof(TestCommand)})
.AddCommandsFrom(new[] {typeof(TestCommand).Assembly})
.AddCommandsFromThisAssembly()
.AllowDebugMode()
.AllowPreviewMode()
.UseTitle("test")
.UseExecutableName("test")
.UseVersionText("test")
.UseDescription("test")
.UseConsole(new VirtualConsole(TextWriter.Null))
.UseCommandFactory(schema => (ICommand) Activator.CreateInstance(schema.Type))
.Build();
}
}
}