public void GetHandler_WhichReturnsIPageWithControls_SetsControls()
        {
            //arrange
            IEnumerable <string> controlNames = null;
            var routeData = new RouteData();

            routeData.DataTokens.Add("controls", new[] { "SomeControl" });
            var httpContext      = new Mock <HttpContextBase>();
            var requestContext   = new RequestContext(httpContext.Object, routeData);
            var pageWithControls = new Mock <STRouting.IPageWithControls>();

            pageWithControls.Setup(p => p.SetControls(It.IsAny <IEnumerable <string> >())).Callback <IEnumerable <string> >(
                c => controlNames = c);
            var pageBuilder = new Mock <STRouting.ISubtextPageBuilder>();

            pageBuilder.Setup(b => b.CreateInstanceFromVirtualPath(It.IsAny <string>(), It.IsAny <Type>())).Returns(
                pageWithControls.Object);
            IRouteHandler subtextRouteHandler = new STRouting.PageRouteHandler("~/aspx/Dtp.aspx", pageBuilder.Object,
                                                                               new Mock <IDependencyResolver>().Object);

            //act
            subtextRouteHandler.GetHttpHandler(requestContext);

            //assert.
            Assert.AreEqual("SomeControl", controlNames.First());
        }
Beispiel #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            // Workaround for Cassini issue with request to /, IIS 6 and IIS 7 Classic mode.
            // In IIS7 Integrated mode, Default.aspx can be deleted.

            var serviceLocator = Bootstrapper.ServiceLocator;
            var pipelineService = new PipelineService(new HttpContextWrapper(HttpContext.Current), serviceLocator);

            var route = new RootRoute(HostInfo.Instance.BlogAggregationEnabled, serviceLocator);
            IRouteHandler routeHandler =
                new Subtext.Framework.Routing.PageRouteHandler(
                    HostInfo.Instance.BlogAggregationEnabled ? "~/aspx/AggDefault.aspx" : "~/aspx/Dtp.aspx",
                    serviceLocator.GetService<ISubtextPageBuilder>(), serviceLocator);

            pipelineService.ProcessRootRequest(route, routeHandler);
        }
        public void GetHandler_WhichReturnsIPageWithControls_SetsControls()
        {
            //arrange
            IEnumerable<string> controlNames = null;
            var routeData = new RouteData();
            routeData.DataTokens.Add("controls", new[] { "SomeControl" });
            var httpContext = new Mock<HttpContextBase>();
            var requestContext = new RequestContext(httpContext.Object, routeData);
            var pageWithControls = new Mock<STRouting.IPageWithControls>();
            pageWithControls.Setup(p => p.SetControls(It.IsAny<IEnumerable<string>>())).Callback<IEnumerable<string>>(
                c => controlNames = c);
            var pageBuilder = new Mock<STRouting.ISubtextPageBuilder>();
            pageBuilder.Setup(b => b.CreateInstanceFromVirtualPath(It.IsAny<string>(), It.IsAny<Type>())).Returns(
                pageWithControls.Object);
            IRouteHandler subtextRouteHandler = new STRouting.PageRouteHandler("~/aspx/Dtp.aspx", pageBuilder.Object,
                                                                     new Mock<IDependencyResolver>().Object);

            //act
            subtextRouteHandler.GetHttpHandler(requestContext);

            //assert.
            Assert.AreEqual("SomeControl", controlNames.First());
        }