You need to pass an instance of Logging.ILogger
to your constructor in your unit test. You can either new up an instance of some type that implements Logging.ILogger
, or you could use a library like Moq to create a mock instance:
var mockLogger = new Moq.Mock<Logging.ILogger>();
var controller = new HomeController(mockLogger.Object);
Alternatively, you could add a default constructor to your HomeController
:
public HomeController() { _logger = new /* create logger */; }
Edit
If you want to use your Ninject Kernel
in your testing, you can do that, but I think it would be overkill for this simple case.
var module = new /* your module, or a test module which configures mocks */;
var kernel = new StandardKernel(module);
var controller = kernel.Get<HomeController>();
You can also use the MockingKernel extension for Ninject if you want some really magical injection, but that is almost certainly overkill for this situation.