This is the fourth in a series of posts illustrating building a custom Windsor registration process. I continue on from the last post where I was using test driven development to build a Windsor Controller Factory for ASP.NET MVC.
Following on from the last post, I have some breaking tests as a result of implementing the IOC container in the controller factory. I now need to revise the particular specifications so that I register the FakeController type with the IOC container. Note that I am also over-riding the SUT's creation so that I can provide a container pre-registered with this type:
[Observations] public class when_a_known_controller_is_requested_from_the_windsor_controller_factory : observations_for_a_sut_with_a_contract<IControllerFactory, WindsorControllerFactory> { private static Type controllerType; private static IController returnedController; private static IWindsorContainer container; private context c = () => { controllerType = typeof (FakeController); container = new WindsorContainer(); container.AddComponentLifeStyle(controllerType.Name, controllerType, LifestyleType.Transient); }; public override IControllerFactory create_sut() { return new WindsorControllerFactory(container); } private because b = () => returnedController = sut.CreateController(null, controllerType.Name); [Observation] public void should_return_an_instance_of_the_controller() { returnedController.should_not_be_null(); } [Observation] public void should_return_the_correct_controller() { returnedController.should_be_an_instance_of<FakeController>(); } }
All of the specifications now pass and I'm happy with a basic implementation.
However in my previous Windsor registration process for Controllers (in the first post of this series) I am registering the controllers with the FullName in lower case.
I want to keep that registration process intact as I want to know the namespace of the type when inspecting the container so I will have to introduce this into my WindsorControllerFactory.
In my next post I'll look at revising my specifications to fit this new requirement.
0 comments: