public void ForegroundColorSpans_are_replaced_with_System_Console_calls_during_non_ANSI_rendering()
        {
            var span = _textSpanFormatter.ParseToSpan(
                $"{ForegroundColorSpan.Red()}red {ForegroundColorSpan.Blue()}blue {ForegroundColorSpan.Green()}green {ForegroundColorSpan.Reset()}or a {ForegroundColorSpan.Rgb(12, 34, 56)}little of each."
            );

            var renderer = new ConsoleRenderer(_terminal, OutputMode.NonAnsi);

            renderer.RenderToRegion(span, new Region(0, 0, 200, 1, false));

            _terminal.Events
                .Should()
                .BeEquivalentSequenceTo(
                    new CursorPositionChanged(new Point(0, 0)),
                    new ForegroundColorChanged(ConsoleColor.DarkRed),
                    new ContentWritten("red "),
                    new ForegroundColorChanged(ConsoleColor.DarkBlue),
                    new ContentWritten("blue "),
                    new ForegroundColorChanged(ConsoleColor.DarkGreen),
                    new ContentWritten("green "),
                    new ColorReset(),
                    new BackgroundColorChanged(ConsoleColor.Black),
                    new ContentWritten("or a "),
                    new ColorReset(),
                    new BackgroundColorChanged(ConsoleColor.Black),
                    new ContentWritten("little of each.")
                );
        }
        public void ForegroundColorSpans_are_removed_during_file_rendering()
        {
            var span = _spanFormatter.ParseToSpan(
                $"{ForegroundColorSpan.Red()}red {ForegroundColorSpan.Blue()}blue {ForegroundColorSpan.Green()}green {ForegroundColorSpan.Reset()}or a {ForegroundColorSpan.Rgb(12, 34, 56)}little of each.");

            var renderer = new ConsoleRenderer(_console, OutputMode.File);

            var expected = "red blue green or a little of each.";

            renderer.RenderToRegion(span, new Region(0, 0, expected.Length, 1, false));

            _console.Out.ToString().Should().Be(expected);
        }
        public void ForegroundColorSpans_are_replaced_with_ANSI_codes_during_ANSI_rendering()
        {
            var span = _spanFormatter.ParseToSpan(
                $"{ForegroundColorSpan.Red()}red {ForegroundColorSpan.Blue()}blue {ForegroundColorSpan.Green()}green {ForegroundColorSpan.Reset()}or a {ForegroundColorSpan.Rgb(12, 34, 56)}little of each.");

            var renderer = new ConsoleRenderer(_console, OutputMode.Ansi);

            renderer.RenderToRegion(span, new Region(0, 0, 200, 1, false));

            _console.Out
            .ToString()
            .Should()
            .Contain(
                $"{Ansi.Color.Foreground.Red.EscapeSequence}red {Ansi.Color.Foreground.Blue.EscapeSequence}blue {Ansi.Color.Foreground.Green.EscapeSequence}green {Ansi.Color.Foreground.Default.EscapeSequence}or a {Ansi.Color.Foreground.Rgb(12, 34, 56).EscapeSequence}little of each.");
        }
Esempio n. 4
0
 public static TextSpan Green(this string value) =>
 new ContainerSpan(ForegroundColorSpan.Green(),
                   new ContentSpan(value),
                   ForegroundColorSpan.Reset());
Esempio n. 5
0
 public static void OutputDebug(this ITerminal terminal, string content) => terminal.OutputColor(ForegroundColorSpan.Green(), content);
Esempio n. 6
0
 public void WriteDebug(string content) => WriteColor(ForegroundColorSpan.Green(), content);