public void BuiltInOptionHelp_NonPrimaryCommand()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInPrimaryCommand) }));
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.All[0].Options.Should().HaveCount(1); // --help
            commands.Primary.Options[0].Should().Be(BuiltInCommandOption.Help);
        }
        public void BuiltInPrimaryCommand()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInPrimaryCommand) }));
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.All.Should().HaveCount(3); // A, B, BuiltInPrimary
            commands.Primary.Should().NotBeNull();
        }
        public void RewriteCommandNamesAsLowerCase()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInPrimaryCommand) }));
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.All.Should().HaveCount(3); // A, B, BuiltInPrimary
            commands.All[0].Name.Should().Be("A");
            commands.All[1].Name.Should().Be("B");
            commands.Primary.Should().NotBeNull();
        }
        public void DisableShellCompletionSupport_BuiltInOptionHelpAndVersion_BuiltInPrimaryCommand()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInPrimaryCommand) }), false);
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.Primary.Options.Should().HaveCount(0);
            commands.Primary.OptionLikeCommands.Should().HaveCount(2); // --help, --version
            commands.Primary.OptionLikeCommands[0].Should().Be(BuiltInOptionLikeCommands.Help);
            commands.Primary.OptionLikeCommands[1].Should().Be(BuiltInOptionLikeCommands.Version);
        }
        public void BuiltInOptionHelpAndVersionAndCompletion_BuiltInPrimaryCommand()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInPrimaryCommand) }), true);
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.Primary.Options.Should().HaveCount(0);
            commands.Primary.OptionLikeCommands.Should().HaveCount(4);                                          // --completion-candidates, --completion, --help, --version
            commands.Primary.OptionLikeCommands[0].Should().Be(BuiltInOptionLikeCommands.CompletionCandidates); // CompletionCandidates option must be first.
            commands.Primary.OptionLikeCommands[1].Should().Be(BuiltInOptionLikeCommands.Completion);
            commands.Primary.OptionLikeCommands[2].Should().Be(BuiltInOptionLikeCommands.Help);
            commands.Primary.OptionLikeCommands[3].Should().Be(BuiltInOptionLikeCommands.Version);
        }
        public void BuiltInOptionHelp_UserOptions()
        {
            var provider = new CoconaBuiltInCommandProvider(new CoconaCommandProvider(new[] { typeof(CommandTestBuiltInHelpUserOptionCommand) }));
            var commands = provider.GetCommandCollection();

            commands.Should().NotBeNull();
            commands.All[0].Options.Should().HaveCount(2);                           // --version, --help
            commands.All[0].Name.Should().Be("A_PrimaryHasVersionOption");
            commands.All[0].Options[0].Should().NotBe(BuiltInCommandOption.Version); // User-implemented --version
            commands.All[0].Options[1].Should().Be(BuiltInCommandOption.Help);
            commands.All[1].Name.Should().Be("B_HasShortHelpOption");
            commands.All[1].Options.Should().HaveCount(1);                        // -h
            commands.All[1].Options[0].Should().NotBe(BuiltInCommandOption.Help); // User-implemented -h
            commands.All[2].Name.Should().Be("C_HasLongHelpOption");
            commands.All[2].Options.Should().HaveCount(1);                        // --help
            commands.All[2].Options[0].Should().NotBe(BuiltInCommandOption.Help); // User-implemented --help
        }