public void AppendShouldProduceLog() { var file = "file1.txt"; var appender = new FileAppender(file); var streamFactory = new Mock <IStreamFactory>(); var stream = new MemoryStream(); var streamWriter = new StreamWriter(stream); streamFactory.Setup(x => x.CreateStreamWriter(It.IsAny <string>())).Returns(streamWriter); appender.SetField("_factory", streamFactory.Object); appender.Append(BuidLogEvent("My Topic", "My Message")); streamWriter.Flush(); var res = GetResult(stream); var expected = _dateString + " - [Info] My Topic: My Message [" + Thread.CurrentThread.ManagedThreadId + "]" + Environment.NewLine; Assert.Equal(expected, res); appender.Append(BuidLogEvent("My Topic2", "My Message2")); streamWriter.Flush(); res = GetResult(stream); appender.Dispose(); expected = _dateString + " - [Info] My Topic2: My Message2 [" + Thread.CurrentThread.ManagedThreadId + "]" + Environment.NewLine; Assert.Equal(expected, res); }