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