Beispiel #1
0
        void InstallHudRoute()
        {
            var url     = routePrefix;
            var handler = new DelegateRouteHandler(context => new HudRequestHandler(container, context));

            Trace.Source.TraceInformation("Installing diagnostics route handler for \"_cassette\".");
            InsertRouteIntoTable(url, handler);
        }
Beispiel #2
0
        void InstallRawFileRoute()
        {
            var url     = routePrefix + "/file/{*path}";
            var handler = new DelegateRouteHandler(
                requestContext => new RawFileRequestHandler(requestContext, container.Application.Bundles)
                );

            Trace.Source.TraceInformation("Installing raw file route handler for \"{0}\".", url);
            InsertRouteIntoTable(url, handler);
        }
Beispiel #3
0
        void InstallBundleRoute <T>()
            where T : Bundle
        {
            var url     = GetBundleRouteUrl <T>();
            var handler = new DelegateRouteHandler(
                requestContext => new BundleRequestHandler <T>(container.Application, requestContext)
                );

            Trace.Source.TraceInformation("Installing {0} route handler for \"{1}\".", typeof(T).FullName, url);
            InsertRouteIntoTable(url, handler);
        }
Beispiel #4
0
        void InstallRawFileRoute(RouteCollection routes)
        {
            const string url     = RoutePrefix + "/file/{*path}";
            var          handler = new DelegateRouteHandler(
                requestContext => new RawFileRequestHandler(requestContext)
                );

            Trace.Source.TraceInformation("Installing raw file route handler for \"{0}\".", url);
            // Insert Cassette's routes at the start of the table,
            // to avoid conflicts with the application's own routes.
            routes.Insert(0, new CassetteRoute(url, handler));
        }
Beispiel #5
0
        void InstallBundleRoute <T>(RouteCollection routes, Func <IBundleContainer> getBundleContainer)
            where T : Bundle
        {
            var url     = GetBundleRouteUrl <T>();
            var handler = new DelegateRouteHandler(
                requestContext => new BundleRequestHandler <T>(getBundleContainer, requestContext)
                );

            Trace.Source.TraceInformation("Installing {0} route handler for \"{1}\".", typeof(T).FullName, url);
            // Insert Cassette's routes at the start of the table,
            // to avoid conflicts with the application's own routes.
            routes.Insert(0, new CassetteRoute(url, handler));
        }
Beispiel #6
0
        void InstallAssetCompileRoute()
        {
            // Used to return compiled coffeescript, less, etc.
            var url     = routePrefix + "/asset/{*path}";
            var handler = new DelegateRouteHandler(
                requestContext => new AssetRequestHandler(
                    requestContext,
                    container.Application.Bundles
                    )
                );

            Trace.Source.TraceInformation("Installing asset route handler for \"{0}\".", url);
            InsertRouteIntoTable(url, handler);
        }
        public void GetHttpHandlerCallsDelegatePassingInTheRequestContextAndReturnsTheCreatedHttpHandler()
        {
            RequestContext actualContext = null;
            var            stubHandler   = Mock.Of <IHttpHandler>();
            var            stubContext   = Mock.Of <RequestContext>();

            var routeHandler = new DelegateRouteHandler(context => {
                actualContext = context;
                return(stubHandler);
            });

            var actualHttpHandler = routeHandler.GetHttpHandler(stubContext);

            actualHttpHandler.ShouldBeSameAs(stubHandler);
            actualContext.ShouldBeSameAs(stubContext);
        }
Beispiel #8
0
        void InstallAssetCompileRoute(RouteCollection routes, Func <IBundleContainer> getBundleContainer)
        {
            // Used to return compiled coffeescript, less, etc.
            const string url     = RoutePrefix + "/asset/{*path}";
            var          handler = new DelegateRouteHandler(
                requestContext => new AssetRequestHandler(
                    requestContext,
                    getBundleContainer
                    )
                );

            Trace.Source.TraceInformation("Installing asset route handler for \"{0}\".", url);
            // Insert Cassette's routes at the start of the table,
            // to avoid conflicts with the application's own routes.
            routes.Insert(0, new CassetteRoute(url, handler));
        }
        public void GetHttpHandlerCallsDelegatePassingInTheRequestContextAndReturnsTheCreatedHttpHandler()
        {
            RequestContext actualContext = null;
            var stubHandler = Mock.Of<IHttpHandler>();
            var stubContext = Mock.Of<RequestContext>();

            var routeHandler = new DelegateRouteHandler(context => {
                actualContext = context;
                return stubHandler;
            });

            var actualHttpHandler = routeHandler.GetHttpHandler(stubContext);

            actualHttpHandler.ShouldBeSameAs(stubHandler);
            actualContext.ShouldBeSameAs(stubContext);
        }