From edf7f23957ad0f165dc42f45050240c4cd5dcb9a Mon Sep 17 00:00:00 2001 From: Frank Ray <52075808+FrankRay78@users.noreply.github.com> Date: Fri, 4 Oct 2024 15:53:24 +0100 Subject: [PATCH] Add strict parsing to almost all branches tests, an obvious omission --- .../Unit/CommandAppTests.Branches.cs | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/src/Tests/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Branches.cs b/src/Tests/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Branches.cs index 4080c6e..fc54784 100644 --- a/src/Tests/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Branches.cs +++ b/src/Tests/Spectre.Console.Cli.Tests/Unit/CommandAppTests.Branches.cs @@ -4,13 +4,16 @@ public sealed partial class CommandAppTests { public sealed class Branches { - [Fact] - public void Should_Run_The_Default_Command_On_Branch() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Run_The_Default_Command_On_Branch(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -29,13 +32,16 @@ public sealed partial class CommandAppTests result.Settings.ShouldBeOfType(); } - [Fact] - public void Should_Throw_When_No_Default_Command_On_Branch() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Throw_When_No_Default_Command_On_Branch(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { }); }); @@ -126,13 +132,16 @@ public sealed partial class CommandAppTests }); } - [Fact] - public void Should_Run_The_Default_Command_On_Branch_On_Branch() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Run_The_Default_Command_On_Branch_On_Branch(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -154,13 +163,16 @@ public sealed partial class CommandAppTests result.Settings.ShouldBeOfType(); } - [Fact] - public void Should_Run_The_Default_Command_On_Branch_On_Branch_With_Arguments() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Run_The_Default_Command_On_Branch_On_Branch_With_Arguments(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -186,13 +198,16 @@ public sealed partial class CommandAppTests }); } - [Fact] - public void Should_Run_The_Default_Command_Not_The_Named_Command_On_Branch() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Run_The_Default_Command_Not_The_Named_Command_On_Branch(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -213,13 +228,16 @@ public sealed partial class CommandAppTests result.Settings.ShouldBeOfType(); } - [Fact] - public void Should_Run_The_Named_Command_Not_The_Default_Command_On_Branch() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Run_The_Named_Command_Not_The_Default_Command_On_Branch(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -246,13 +264,16 @@ public sealed partial class CommandAppTests }); } - [Fact] - public void Should_Allow_Multiple_Branches_Multiple_Commands() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Allow_Multiple_Branches_Multiple_Commands(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -282,13 +303,16 @@ public sealed partial class CommandAppTests }); } - [Fact] - public void Should_Allow_Single_Branch_Multiple_Commands() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Allow_Single_Branch_Multiple_Commands(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => { @@ -315,13 +339,16 @@ public sealed partial class CommandAppTests }); } - [Fact] - public void Should_Allow_Single_Branch_Single_Command() + [Theory] + [InlineData(true)] + [InlineData(false)] + public void Should_Allow_Single_Branch_Single_Command(bool strictParsing) { // Given var app = new CommandAppTester(); app.Configure(config => { + config.Settings.StrictParsing = strictParsing; config.PropagateExceptions(); config.AddBranch("animal", animal => {