Esempio n. 1
0
            public void Should_throw_if_controller_type_cannot_be_resolved()
            {
                var requestContext = new RequestContext(MvcMockHelpers.DynamicHttpContextBase(), new RouteData());

                //HttpException(0x194,
                IControllerFactory controllerFactory = new IoCControllerFactory(_dependencyResolver);

                controllerFactory.InitializeWithControllerTypes(typeof(IocTestController));

                controllerFactory.CreateController(requestContext, "DoesNotExist");
            }
Esempio n. 2
0
            public void Should_call_into_the_static_resolver_to_create_a_controller()
            {
                var requestContext = new RequestContext(MvcMockHelpers.DynamicHttpContextBase(), new RouteData());

                IControllerFactory controllerFactory = new IoCControllerFactory();

                controllerFactory.InitializeWithControllerTypes(typeof(IocTestController));

                IController controller = controllerFactory.CreateController(requestContext, "IocTest");

                Assert.That(controller, Is.TypeOf(typeof(IocTestController)));
            }
Esempio n. 3
0
            public void Should_call_into_the_resolver_to_create_a_controller()
            {
                var requestContext = new RequestContext(MvcMockHelpers.DynamicHttpContextBase(), new RouteData());

                _dependencyResolver.Expect(r => r.GetImplementationOf <IController>(typeof(IocTestController)))
                .Return(new IocTestController());

                _dependencyResolver.Replay();

                IControllerFactory controllerFactory = new IoCControllerFactory(_dependencyResolver);

                controllerFactory.InitializeWithControllerTypes(typeof(IocTestController));

                IController controller = controllerFactory.CreateController(requestContext, "IocTest");

                Assert.That(controller, Is.TypeOf(typeof(IocTestController)));
                _dependencyResolver.VerifyAllExpectations();
            }