Пример #1
0
        public void DebugMode__ReturnsValueOrDefault()
        {
            MockXmlOptions.Setup(o => o.OutputMode).Returns((OutputMode?)null);
            OutputMode result = TheOptions.OutputMode;

            result.Should().Be(SettingsWrapper.OptionOutputModeDefaultValue);

            MockXmlOptions.Setup(o => o.OutputMode).Returns(OutputMode.Verbose);
            result = TheOptions.OutputMode;
            result.Should().Be(OutputMode.Verbose);
        }
        public async Task Sets_output_mode_to_Ansi_when_specified_by_output_directive(OutputMode specifiedOutputMode)
        {
            var        console            = new TestConsole();
            OutputMode detectedOutputMode = OutputMode.Auto;

            var command = new Command("hello");

            command.SetHandler((InvocationContext ctx) =>
            {
                detectedOutputMode = ctx.Console.DetectOutputMode();
                return(Task.FromResult(0));
            });

            var parser = new CommandLineBuilder(command)
                         .UseAnsiTerminalWhenAvailable()
                         .Build();

            await parser.InvokeAsync($"[output:{specifiedOutputMode}]", console);

            detectedOutputMode.Should().Be(specifiedOutputMode);
        }
Пример #3
0
        public async Task Sets_output_mode_to_Ansi_when_specified_by_output_directive(OutputMode specifiedOutputMode)
        {
            var        console            = new TestConsole();
            OutputMode detectedOutputMode = OutputMode.Auto;

            var command = new Command("hello")
            {
                Handler = CommandHandler.Create((IConsole c) =>
                {
                    detectedOutputMode = c.DetectOutputMode();
                })
            };

            var parser = new CommandLineBuilder(command)
                         .UseAnsiTerminalWhenAvailable()
                         .Build();

            await parser.InvokeAsync($"[output:{specifiedOutputMode}]", console);

            detectedOutputMode.Should().Be(specifiedOutputMode);
        }