public void TestNewLinesAndSingleCharsAreIgnored() { var log = new RollingMemoryLog(Severity.Diagnostic); using var logger = new Logger(synchronous: true, log); var context = new Context(logger); var twa = new TextWriterAdapter(context, Severity.Info); twa.WriteLine(); twa.WriteLine(); twa.WriteLine(); twa.Write('H'); twa.Write('e'); twa.Write('l'); twa.Write('l'); twa.Write('o'); log.RecentEntries(1).Should().BeEmpty(); }
public void TestWritesInInfoMode() { var log = new RollingMemoryLog(Severity.Diagnostic); using var logger = new Logger(synchronous: true, log); var context = new Context(logger); var twa = new TextWriterAdapter(context, Severity.Info); twa.WriteLine("Hello World!"); log.RecentEntries(1).First().Should().Contain("Hello World!"); }
public void WriteLineTest() { var outputMock = new Mock <ITestOutputHelper>(); outputMock.Setup(x => x.WriteLine(It.IsAny <string>())).Callback <string>(CaptureText); var output = outputMock.Object; var adapter = new TextWriterAdapter(output); adapter.WriteLine("Hello World"); Assert.Equal("Hello World", _capturedText); adapter.Write("H"); adapter.Write('\r'); adapter.Write('e'); adapter.Write('l'); adapter.Write('o'); adapter.Write('\n'); Assert.Equal("H\relo", _capturedText); adapter.Write('\r'); adapter.Write('\n'); Assert.Equal(string.Empty, _capturedText); }