public void GetControllerInstanceTestWithBlankRequestAndExistingType()
        {
            MockRepository mocks = new MockRepository();
            IUnityContainer container = (IUnityContainer) mocks.StrictMock<IUnityContainer>();
            IController expected = mocks.Stub<IController>();

            //First Param : The request context used by GetControllerInstance for resolving the right controller based on the HttpContext and all routeData available
            RequestContext requestContext = new RequestContext(new FakeHttpContext(""), new RouteData());

            //Second Param : The type of the controller needed
            Type controllerType = typeof(IController);

            //Create the target
            UnityControllerFactory_Accessor target = new UnityControllerFactory_Accessor(container);

            //respond
            IController actual;

            //Record call to context and request used by MVC
            using (mocks.Record())
            {
                Expect.Call(container.Resolve(typeof(IController), null)).Return((IController)expected);
            }

            //Play the test
            using (mocks.Playback())
            {
                actual = target.GetControllerInstance(requestContext, controllerType);
            }

            //Test returning value
            Assert.AreEqual(expected, actual);
        }
        public void GetControllerInstanceTestWithBlankRequestAndNullType()
        {
            MockRepository mocks = new MockRepository();

            //Mock the HttpRequest object for returning a blank path from the Path Property
            FakeHttpRequest request = (FakeHttpRequest)mocks.PartialMock(typeof(FakeHttpRequest),"",null,null);
            //Mock the httpContext object for returning the mocked Request from the request property
            FakeHttpContext context = (FakeHttpContext)mocks.PartialMock(typeof(FakeHttpContext), "");

            //First Param : The request context used by GetControllerInstance for resolving the right controller based on the HttpContext and all routeData available
            RequestContext requestContext = new RequestContext(context, new RouteData());

            //Second Param : The type of the controller needed : null for this case
            Type controllerType = null;

             //HttpException is managed by getControllerInstance and will return null
            IController expected = null;

            // no need to use a container. will not test this case
            IUnityContainer container = null;
            //Create the target
            UnityControllerFactory_Accessor target = new UnityControllerFactory_Accessor(container);

            //respond
            IController actual;

            //Record call to context and request used by MVC
            using (mocks.Record())
            {
                Expect.Call(context.Request).Return(request);
                Expect.Call(request.Path).Return("");
            }

            //Play the test
            using (mocks.Playback())
            {
                actual = target.GetControllerInstance(requestContext, controllerType);
            }

            //Test returning value
            Assert.AreEqual(expected, actual);
        }
        public void GetControllerInstanceTestWithNullRequestAndNullType()
        {
            IUnityContainer param0 = null;
            UnityControllerFactory_Accessor target = new UnityControllerFactory_Accessor(param0);
            RequestContext requestContext = null;
            Type controllerType = null;
            IController actual;

            actual = target.GetControllerInstance(requestContext, controllerType);
            Assert.IsNull(actual);
        }