I'm using dependency injection to supply one of my classes (SomethingManager) with something it needs (SomethingEngine). In the constructor of the SomethingManager I set some properties on SomethingEngine. SomethingManager then exposes a set of methods which wrap up calls to SomethingEngine as well as some small bits of logic. I would like to unit test my constructor to test the logic of the properties I set initially and also to ensure the correct properties are set. In order to examine the results of my tests I'm looking at exposing a get accessor to ISomethingEngine on the SomethingManager but this doesn't seem like a nice solution.
What is a better way to do this?
private IEngine _engine;
public Manager(IEngine engine)
{
_engine = engine;
_engine.Prop1 = "a"; //etc
}
Now in order to test I really need to make IEngine public (or at least internal) and mark it visible to my unit test project
IEngine
defined and how do you create anengine
to inject intoManager
?InternalsVisibleTo
andinternal
if you want to test implementation details (I typically only need it for public methods on internal types, not internal fields/methods on public types).