-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
help
command is no longer supported if an app has only one command
- Loading branch information
Showing
6 changed files
with
194 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
tests/ConsoleAppFramework.Integration.Test/NamedSingleCommandTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Microsoft.Extensions.Hosting; | ||
using Xunit; | ||
|
||
// ReSharper disable InconsistentNaming | ||
|
||
namespace ConsoleAppFramework.Integration.Test | ||
{ | ||
public partial class NamedSingleCommandTest | ||
{ | ||
[Fact] | ||
public void NamedCommand_NoArgs_CommandIsNotSpecified() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_NoArgs>(args); | ||
console.Output.Should().Contain("Usage:"); | ||
console.Output.Should().Contain("Commands:"); | ||
} | ||
|
||
[Fact] | ||
public void NamedCommand_NoArgs_Invoke() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { "hello" }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_NoArgs>(args); | ||
console.Output.Should().Contain("Hello"); | ||
} | ||
|
||
[Fact] | ||
public void NamedCommand_NoArgs_CommandHelp() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { "help", "hello" }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_NoArgs>(args); | ||
console.Output.Should().Contain("Usage:"); | ||
console.Output.Should().Contain(" hello"); | ||
} | ||
|
||
public class CommandTests_Single_Named_NoArgs : ConsoleAppBase | ||
{ | ||
[Command("hello")] | ||
public void Hello() => Console.WriteLine("Hello"); | ||
} | ||
|
||
[Fact] | ||
public void NamedCommand_OneArg_CommandIsNotSpecified() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_OneArg>(args); | ||
console.Output.Should().Contain("Usage:"); | ||
console.Output.Should().Contain("Commands:"); | ||
} | ||
|
||
[Fact] | ||
public void NamedCommand_OneArg_Invoke() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { "hello", "Cysharp" }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_OneArg>(args); | ||
console.Output.Should().Contain("Hello Cysharp"); | ||
} | ||
|
||
[Fact] | ||
public void NamedCommand_OneArg_CommandHelp() | ||
{ | ||
using var console = new CaptureConsoleOutput(); | ||
var args = new string[] { "help", "hello" }; | ||
Host.CreateDefaultBuilder().RunConsoleAppFrameworkAsync<CommandTests_Single_Named_OneArg>(args); | ||
console.Output.Should().Contain("Usage:"); | ||
console.Output.Should().Contain("Arguments:"); | ||
} | ||
|
||
public class CommandTests_Single_Named_OneArg : ConsoleAppBase | ||
{ | ||
[Command("hello")] | ||
public void Hello([Option(0)]string name) => Console.WriteLine($"Hello {name}"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters