mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-10-25 15:19:23 +00:00
fixed line-endings
This commit is contained in:
committed by
Patrik Svensson
parent
989c0b9904
commit
44300c871f
@@ -1,5 +1,5 @@
|
||||
using Spectre.Console.Cli.Tests.Data.Help;
|
||||
|
||||
using Spectre.Console.Cli.Tests.Data.Help;
|
||||
|
||||
namespace Spectre.Console.Tests.Unit.Cli;
|
||||
|
||||
public sealed partial class CommandAppTests
|
||||
@@ -93,12 +93,12 @@ public sealed partial class CommandAppTests
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("cat", "--help");
|
||||
var result = fixture.Run("cat", "--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Branch_Called_Without_Help")]
|
||||
public Task Should_Output_Branch_When_Called_Without_Help_Option()
|
||||
@@ -110,27 +110,27 @@ public sealed partial class CommandAppTests
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<CatSettings>("cat", animal =>
|
||||
{
|
||||
animal.SetDescription("Contains settings for a cat.");
|
||||
animal.SetDescription("Contains settings for a cat.");
|
||||
animal.AddCommand<LionCommand>("lion");
|
||||
});
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("cat");
|
||||
var result = fixture.Run("cat");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Branch_Default_Greeter")]
|
||||
[Expectation("Branch_Default_Greeter")]
|
||||
public Task Should_Output_Branch_With_Default_Correctly()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<OptionalArgumentWithDefaultValueSettings>("branch", animal =>
|
||||
{
|
||||
animal.SetDefaultCommand<GreeterCommand>();
|
||||
@@ -138,8 +138,8 @@ public sealed partial class CommandAppTests
|
||||
});
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("branch", "--help");
|
||||
// When
|
||||
var result = fixture.Run("branch", "--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
@@ -186,7 +186,7 @@ public sealed partial class CommandAppTests
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("cat", "lion", "--help");
|
||||
var result = fixture.Run("cat", "lion", "--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
@@ -233,13 +233,13 @@ public sealed partial class CommandAppTests
|
||||
[Theory]
|
||||
[InlineData(null, "EN")]
|
||||
[InlineData("", "EN")]
|
||||
[InlineData("en", "EN")]
|
||||
[InlineData("en", "EN")]
|
||||
[InlineData("en-EN", "EN")]
|
||||
[InlineData("fr", "FR")]
|
||||
[InlineData("fr", "FR")]
|
||||
[InlineData("fr-FR", "FR")]
|
||||
[InlineData("sv", "SV")]
|
||||
[InlineData("sv", "SV")]
|
||||
[InlineData("sv-SE", "SV")]
|
||||
[InlineData("de", "DE")]
|
||||
[InlineData("de", "DE")]
|
||||
[InlineData("de-DE", "DE")]
|
||||
[Expectation("Default_Without_Args_Additional")]
|
||||
public Task Should_Output_Default_Command_And_Additional_Commands_When_Default_Command_Has_Required_Parameters_And_Is_Called_Without_Args_Localised(string culture, string expectationPrefix)
|
||||
@@ -281,106 +281,106 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Custom_Help_Registered_By_Instance")]
|
||||
public Task Should_Output_Custom_Help_When_Registered_By_Instance()
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Create the custom help provider
|
||||
var helpProvider = new CustomHelpProvider(configurator.Settings, "1.0");
|
||||
|
||||
// Register the custom help provider instance
|
||||
registrar.RegisterInstance(typeof(IHelpProvider), helpProvider);
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Create the custom help provider
|
||||
var helpProvider = new CustomHelpProvider(configurator.Settings, "1.0");
|
||||
|
||||
// Register the custom help provider instance
|
||||
registrar.RegisterInstance(typeof(IHelpProvider), helpProvider);
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Custom_Help_Registered_By_Type")]
|
||||
public Task Should_Output_Custom_Help_When_Registered_By_Type()
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Register the custom help provider type
|
||||
registrar.Register(typeof(IHelpProvider), typeof(RedirectHelpProvider));
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Register the custom help provider type
|
||||
registrar.Register(typeof(IHelpProvider), typeof(RedirectHelpProvider));
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Custom_Help_Configured_By_Instance")]
|
||||
public Task Should_Output_Custom_Help_When_Configured_By_Instance()
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Configure the custom help provider instance
|
||||
configurator.SetHelpProvider(new CustomHelpProvider(configurator.Settings, "1.0"));
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Configure the custom help provider instance
|
||||
configurator.SetHelpProvider(new CustomHelpProvider(configurator.Settings, "1.0"));
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Custom_Help_Configured_By_Type")]
|
||||
public Task Should_Output_Custom_Help_When_Configured_By_Type()
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Configure the custom help provider type
|
||||
configurator.SetHelpProvider<RedirectHelpProvider>();
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
{
|
||||
var registrar = new DefaultTypeRegistrar();
|
||||
|
||||
// Given
|
||||
var fixture = new CommandAppTester(registrar);
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
// Configure the custom help provider type
|
||||
configurator.SetHelpProvider<RedirectHelpProvider>();
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run();
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples")]
|
||||
@@ -391,20 +391,20 @@ public sealed partial class CommandAppTests
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// All root examples should be shown
|
||||
configurator.AddExample("dog", "--name", "Rufus", "--age", "12", "--good-boy");
|
||||
configurator.AddExample("dog", "--name", "Luna");
|
||||
configurator.AddExample("dog", "--name", "Charlie");
|
||||
configurator.AddExample("dog", "--name", "Bella");
|
||||
configurator.AddExample("dog", "--name", "Daisy");
|
||||
|
||||
// All root examples should be shown
|
||||
configurator.AddExample("dog", "--name", "Rufus", "--age", "12", "--good-boy");
|
||||
configurator.AddExample("dog", "--name", "Luna");
|
||||
configurator.AddExample("dog", "--name", "Charlie");
|
||||
configurator.AddExample("dog", "--name", "Bella");
|
||||
configurator.AddExample("dog", "--name", "Daisy");
|
||||
configurator.AddExample("dog", "--name", "Milo");
|
||||
configurator.AddExample("horse", "--name", "Brutus");
|
||||
configurator.AddExample("horse", "--name", "Sugar", "--IsAlive", "false");
|
||||
configurator.AddExample("horse", "--name", "Cash");
|
||||
configurator.AddExample("horse", "--name", "Dakota");
|
||||
configurator.AddExample("horse", "--name", "Cisco");
|
||||
configurator.AddExample("horse", "--name", "Spirit");
|
||||
configurator.AddExample("horse", "--name", "Brutus");
|
||||
configurator.AddExample("horse", "--name", "Sugar", "--IsAlive", "false");
|
||||
configurator.AddExample("horse", "--name", "Cash");
|
||||
configurator.AddExample("horse", "--name", "Dakota");
|
||||
configurator.AddExample("horse", "--name", "Cisco");
|
||||
configurator.AddExample("horse", "--name", "Spirit");
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog");
|
||||
configurator.AddCommand<HorseCommand>("horse");
|
||||
@@ -415,10 +415,10 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children")]
|
||||
[Expectation("Root_Examples_Children")]
|
||||
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:SingleLineCommentsMustNotBeFollowedByBlankLine", Justification = "Single line comment is relevant to several code blocks that follow.")]
|
||||
public Task Should_Output_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
@@ -426,135 +426,24 @@ public sealed partial class CommandAppTests
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// It should be capped to the first 5 examples by default
|
||||
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// It should be capped to the first 5 examples by default
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children_Eight")]
|
||||
public Task Should_Output_Eight_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Show the first 8 examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 8;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children_Twelve")]
|
||||
public Task Should_Output_All_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Show all examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = int.MaxValue;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children_None")]
|
||||
public Task Should_Not_Output_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Do not show examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 0;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
@@ -566,7 +455,118 @@ public sealed partial class CommandAppTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Leafs")]
|
||||
[Expectation("Root_Examples_Children_Eight")]
|
||||
public Task Should_Output_Eight_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Show the first 8 examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 8;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children_Twelve")]
|
||||
public Task Should_Output_All_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Show all examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = int.MaxValue;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Children_None")]
|
||||
public Task Should_Not_Output_Examples_Defined_On_Direct_Children_If_Root_Has_No_Examples()
|
||||
{
|
||||
// Given
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// Do not show examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 0;
|
||||
|
||||
configurator.AddCommand<DogCommand>("dog")
|
||||
.WithExample("dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("dog", "--name", "Luna")
|
||||
.WithExample("dog", "--name", "Charlie")
|
||||
.WithExample("dog", "--name", "Bella")
|
||||
.WithExample("dog", "--name", "Daisy")
|
||||
.WithExample("dog", "--name", "Milo");
|
||||
|
||||
configurator.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("horse", "--name", "Brutus")
|
||||
.WithExample("horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("horse", "--name", "Cash")
|
||||
.WithExample("horse", "--name", "Dakota")
|
||||
.WithExample("horse", "--name", "Cisco")
|
||||
.WithExample("horse", "--name", "Spirit");
|
||||
});
|
||||
|
||||
// When
|
||||
var result = fixture.Run("--help");
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Leafs")]
|
||||
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1512:SingleLineCommentsMustNotBeFollowedByBlankLine", Justification = "Single line comment is relevant to several code blocks that follow.")]
|
||||
public Task Should_Output_Examples_Defined_On_Leaves_If_No_Other_Examples_Are_Found()
|
||||
{
|
||||
@@ -577,24 +577,24 @@ public sealed partial class CommandAppTests
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// It should be capped to the first 5 examples by default
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// It should be capped to the first 5 examples by default
|
||||
|
||||
animal.AddCommand<DogCommand>("dog")
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
|
||||
animal.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Spirit");
|
||||
});
|
||||
});
|
||||
@@ -604,10 +604,10 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Leafs_Eight")]
|
||||
[Expectation("Root_Examples_Leafs_Eight")]
|
||||
public Task Should_Output_Eight_Examples_Defined_On_Leaves_If_No_Other_Examples_Are_Found()
|
||||
{
|
||||
// Given
|
||||
@@ -617,25 +617,25 @@ public sealed partial class CommandAppTests
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Show the first 8 examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 8;
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Show the first 8 examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 8;
|
||||
|
||||
animal.AddCommand<DogCommand>("dog")
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
|
||||
animal.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Spirit");
|
||||
});
|
||||
});
|
||||
@@ -645,10 +645,10 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Leafs_Twelve")]
|
||||
[Expectation("Root_Examples_Leafs_Twelve")]
|
||||
public Task Should_Output_All_Examples_Defined_On_Leaves_If_No_Other_Examples_Are_Found()
|
||||
{
|
||||
// Given
|
||||
@@ -658,25 +658,25 @@ public sealed partial class CommandAppTests
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Show all examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = int.MaxValue;
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Show all examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = int.MaxValue;
|
||||
|
||||
animal.AddCommand<DogCommand>("dog")
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
|
||||
animal.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Spirit");
|
||||
});
|
||||
});
|
||||
@@ -686,10 +686,10 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Root_Examples_Leafs_None")]
|
||||
[Expectation("Root_Examples_Leafs_None")]
|
||||
public Task Should_Not_Output_Examples_Defined_On_Leaves_If_No_Other_Examples_Are_Found()
|
||||
{
|
||||
// Given
|
||||
@@ -699,25 +699,25 @@ public sealed partial class CommandAppTests
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Do not show examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 0;
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// Do not show examples defined on the direct children
|
||||
configurator.Settings.MaximumIndirectExamples = 0;
|
||||
|
||||
animal.AddCommand<DogCommand>("dog")
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
.WithExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy")
|
||||
.WithExample("animal", "dog", "--name", "Luna")
|
||||
.WithExample("animal", "dog", "--name", "Charlie")
|
||||
.WithExample("animal", "dog", "--name", "Bella")
|
||||
.WithExample("animal", "dog", "--name", "Daisy")
|
||||
.WithExample("animal", "dog", "--name", "Milo");
|
||||
|
||||
animal.AddCommand<HorseCommand>("horse")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Brutus")
|
||||
.WithExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false")
|
||||
.WithExample("animal", "horse", "--name", "Cash")
|
||||
.WithExample("animal", "horse", "--name", "Dakota")
|
||||
.WithExample("animal", "horse", "--name", "Cisco")
|
||||
.WithExample("animal", "horse", "--name", "Spirit");
|
||||
});
|
||||
});
|
||||
@@ -737,23 +737,23 @@ public sealed partial class CommandAppTests
|
||||
var fixture = new CommandAppTester();
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.SetApplicationName("myapp");
|
||||
configurator.AddBranch<AnimalSettings>("animal", animal =>
|
||||
{
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// All branch examples should be shown
|
||||
animal.AddExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy");
|
||||
animal.AddExample("animal", "dog", "--name", "Luna");
|
||||
animal.AddExample("animal", "dog", "--name", "Charlie");
|
||||
animal.AddExample("animal", "dog", "--name", "Bella");
|
||||
animal.AddExample("animal", "dog", "--name", "Daisy");
|
||||
animal.AddExample("animal", "dog", "--name", "Milo");
|
||||
animal.AddExample("animal", "horse", "--name", "Brutus");
|
||||
animal.AddExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false");
|
||||
animal.AddExample("animal", "horse", "--name", "Cash");
|
||||
animal.AddExample("animal", "horse", "--name", "Dakota");
|
||||
animal.AddExample("animal", "horse", "--name", "Cisco");
|
||||
animal.SetDescription("The animal command.");
|
||||
|
||||
// All branch examples should be shown
|
||||
animal.AddExample("animal", "dog", "--name", "Rufus", "--age", "12", "--good-boy");
|
||||
animal.AddExample("animal", "dog", "--name", "Luna");
|
||||
animal.AddExample("animal", "dog", "--name", "Charlie");
|
||||
animal.AddExample("animal", "dog", "--name", "Bella");
|
||||
animal.AddExample("animal", "dog", "--name", "Daisy");
|
||||
animal.AddExample("animal", "dog", "--name", "Milo");
|
||||
animal.AddExample("animal", "horse", "--name", "Brutus");
|
||||
animal.AddExample("animal", "horse", "--name", "Sugar", "--IsAlive", "false");
|
||||
animal.AddExample("animal", "horse", "--name", "Cash");
|
||||
animal.AddExample("animal", "horse", "--name", "Dakota");
|
||||
animal.AddExample("animal", "horse", "--name", "Cisco");
|
||||
animal.AddExample("animal", "horse", "--name", "Spirit");
|
||||
|
||||
animal.AddCommand<DogCommand>("dog")
|
||||
@@ -768,7 +768,7 @@ public sealed partial class CommandAppTests
|
||||
|
||||
// Then
|
||||
return Verifier.Verify(result.Output);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Expectation("Default_Examples")]
|
||||
@@ -780,13 +780,13 @@ public sealed partial class CommandAppTests
|
||||
fixture.Configure(configurator =>
|
||||
{
|
||||
configurator.SetApplicationName("myapp");
|
||||
|
||||
// All root examples should be shown
|
||||
configurator.AddExample("--name", "Rufus", "--age", "12", "--good-boy");
|
||||
configurator.AddExample("--name", "Luna");
|
||||
configurator.AddExample("--name", "Charlie");
|
||||
configurator.AddExample("--name", "Bella");
|
||||
configurator.AddExample("--name", "Daisy");
|
||||
|
||||
// All root examples should be shown
|
||||
configurator.AddExample("--name", "Rufus", "--age", "12", "--good-boy");
|
||||
configurator.AddExample("--name", "Luna");
|
||||
configurator.AddExample("--name", "Charlie");
|
||||
configurator.AddExample("--name", "Bella");
|
||||
configurator.AddExample("--name", "Daisy");
|
||||
configurator.AddExample("--name", "Milo");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user