From b1d01898b6592ce48f61518f1a39b703a2c21467 Mon Sep 17 00:00:00 2001 From: Tyrrrz Date: Sat, 10 Jul 2021 19:43:21 +0300 Subject: [PATCH] Add test for preamble omission --- CliFx.Tests/ConsoleSpecs.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/CliFx.Tests/ConsoleSpecs.cs b/CliFx.Tests/ConsoleSpecs.cs index 7b7715a..cfdd60e 100644 --- a/CliFx.Tests/ConsoleSpecs.cs +++ b/CliFx.Tests/ConsoleSpecs.cs @@ -1,6 +1,9 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Text; using System.Threading.Tasks; +using CliFx.Infrastructure; using CliFx.Tests.Utils; using CliWrap; using CliWrap.Buffered; @@ -135,5 +138,22 @@ public class Command : ICommand stdOut.Trim().Should().Be("Hello world"); stdErr.Trim().Should().Be("Hello world"); } + + [Fact] + public void Console_does_not_emit_preamble_when_used_with_encoding_that_has_it() + { + // Arrange + using var buffer = new MemoryStream(); + using var consoleWriter = new ConsoleWriter(FakeConsole, buffer, Encoding.UTF8); + + // Act + consoleWriter.Write("Hello world"); + consoleWriter.Flush(); + + var output = consoleWriter.Encoding.GetString(buffer.ToArray()); + + // Assert + output.Should().Be("Hello world"); + } } } \ No newline at end of file