问题描述
我正在寻找一种使用Nlog
通常,我所有的课程都有私人成员_logger
例如:
using NLog;
public class MyClass {
private readonly Logger _logger;
public MyClass(){
this._logger = LogManager.GetCurrentClassLogger();
}
}
每当我需要记录消息时,我都会打电话
_logger.info('message')
由于不允许C#动态注入Log对象,所以我想知道如何在单元测试中测试消息?我正在以这种方式思考。
[TestMethod]
public void TestLogMessage() {
var testGerrits = MyClass();
// mock the logger?
Assert.AreEqual(logger[0],"expected message");
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)