mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Add smoke tests for CliApplicationBuilder
This commit is contained in:
15
CliFx.Tests/CliApplicationBuilderTests.Commands.cs
Normal file
15
CliFx.Tests/CliApplicationBuilderTests.Commands.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
CliFx.Tests/CliApplicationBuilderTests.cs
Normal file
37
CliFx.Tests/CliApplicationBuilderTests.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user