There are problems with mocking
Log4Net. Here's the production code:
public class Log4NetTest
{
public void TestRun()
{
log4net.Config.XmlConfigurator.Configure();
var log = LogManager.GetLogger(typeof(Log4NetTest));
log.Error("Worse");
log.Info("Dont Kid");
}
}
public class Log4NetTypeMock
{
public static readonly ILog log
= LogManager.GetLogger(typeof(Log4NetTypeMock))
;
public static readonly Log4NetTest log4Net;
}
Now run test two tests:
[Test, Isolated]
public void Test2()
{
Isolate.WhenCalled(() => Log4NetTypeMock.log4Net)
.ReturnRecursiveFake();
Assert.AreEqual(2, 1 + 1);
}
The test passes, fine.
But now uncomment this line
= LogManager.GetLogger(typeof(Log4NetTypeMock))
Run the Test2() again, this time, it fails!