I have an abstract class with a dependency that I would like to use unit test:
public abstract class BaseClass { public BaseClass(IDependency dep) { ... } public virtual void TestMethod() { ... } ... }
I want to test this class using NInject MockingKernel , so I did the following:
using (var k = new MoqMockingKernel()) { k.Bind<IDependency>().ToMock(); k.Bind<BaseClass>().ToMock(); k.GetMock<BaseClass>().CallBase = true; var sut = k.Get<BaseClass>(); sut.TestMethod(); k.GetMock<BaseClass>().Verify(...); }
but i have a problem. He is looking for a parameterless constructor to create partial BaseClass prototyping, and not to convey built-in interdependence.
Looking at the source , it seems that MockingKernel will never pass arguments to the layout at creation time.
Is there a way to create a partial layout with MockingKernel?
source share