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."); }
public void Spans_have_a_start_relative_to_the_parent_span() { var span = new ContainerSpan( ForegroundColorSpan.Red(), new ContentSpan("first"), ForegroundColorSpan.Blue(), new ContentSpan("second"), ForegroundColorSpan.Reset()); span[0].Start.Should().Be(0); span[1].Start.Should().Be(0); span[2].Start.Should().Be("first".Length); span[3].Start.Should().Be("first".Length); span[4].Start.Should().Be("firstsecond".Length); }
public void Span_starts_update_when_parent_is_added_to_another_parent_span() { var innerContainerSpan = new ContainerSpan( ForegroundColorSpan.Red(), new ContentSpan("second"), ForegroundColorSpan.Blue(), new ContentSpan("third"), ForegroundColorSpan.Reset() ); var outerContainer = new ContainerSpan(new ContentSpan("first"), innerContainerSpan); innerContainerSpan[0].Start.Should().Be("first".Length); innerContainerSpan[1].Start.Should().Be("first".Length); innerContainerSpan[2].Start.Should().Be("firstsecond".Length); innerContainerSpan[3].Start.Should().Be("firstsecond".Length); innerContainerSpan[4].Start.Should().Be("firstsecondthird".Length); }