I am doing an MVC project with structuremap as an IOC container. We are doing TDD, and I want to set up my dependencies so that its easy to work with, and so that its easy to test.
How should I best set up the graph of dependencies for the below fictional illustrated graph ?
- ApplicationController
- Controller
- AuthenticationService
- UserRepository
- AuthenticationService
- Controller
Do you inject the userrepository on the controller, and further from the in the authenticationservice? And what if the graph is deeper - will you not get a lot of dependencies starting on the controller?
If you have a dependency on you applicationcontroller, do you also inject that on the controller, and that way up on the base?
If I let the container resolve the instance somewhere in the middle of the graph, I would have to setup the container for testing? Is that a good thing to do, or best avoided?
Is there another way, that I am not seeing?