Bar = bar;
Baz = baz;
var foo =
foo.Arrange<IBaz>(baz => baz.GetString()).Returns(
var actualResult = foo.Instance.Bar.Baz.GetString();
Given the above code, a null reference exception is thrown on line 32.
I am using NInject to do constructor dependency injection. I have a large hierarchy of classes that take in their dependencies in their constructors as Foo and Bar do above. I want all of my concrete classes to be instantiated and only have the interfaces get mocked. In the above example, I want a real Bar constructed and a real Foo constructed but I want IBaz to be mocked.
I am aware that in the above scenario I could just manually construct a Foo, passing in a manually constructed Bar, but in my scenario, the dependency hierarchy is large and complex and interfaces wrap all external (not my code calls). Is there an easy way to tell the MockingContainer<Foo> that it should mock all interfaces but not mock any concrete classes (actually instantiate them).
As I said, I am using Ninject to instantiate my classes and it does the right thing everywhere. I understand that the automocking container is backed by Ninject. Is there a way I can bind certain interfaces/classes to JustMock? In the above example I could do something like:
kernel.Bind<IBaz>().To<Mock<IBaz>>()? That way I could just use Ninject to instantiate my object hierarchy, but tell it which interfaces I want it to bind to JustMock mocked instances.