当前位置: 首页>>代码示例>>C#>>正文


C# Mock.FakeRequest方法代码示例

本文整理汇总了C#中Mock.FakeRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.FakeRequest方法的具体用法?C# Mock.FakeRequest怎么用?C# Mock.FakeRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mock的用法示例。


在下文中一共展示了Mock.FakeRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequestWithoutSubfolder_ForAshxFileInDirectory_GetsHandlerInPhysicalDirectory

        public void RequestWithoutSubfolder_ForAshxFileInDirectory_GetsHandlerInPhysicalDirectory()
        {
            //arrange
            string virtualPath = string.Empty;
            var routeData = new RouteData
                                {
                                    Route = new DirectoryRoute("admin", new Mock<IDependencyResolver>().Object)
                                };
            ;
            routeData.Values.Add("pathinfo", "foo.ashx");
            var pageBuilder = new Mock<ISubtextPageBuilder>();
            var httpHandler = new Mock<IHttpHandler>();
            pageBuilder.Setup(b => b.CreateInstanceFromVirtualPath(It.IsAny<string>(), It.IsAny<Type>())).Returns(
                httpHandler.Object).Callback<string, Type>((vpath, type) => virtualPath = vpath);
            IRouteHandler routeHandler = new DirectoryRouteHandler(pageBuilder.Object, new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/admin/foo.ashx");
            var requestContext = new RequestContext(httpContext.Object, routeData);

            //act
            IHttpHandler handler = routeHandler.GetHttpHandler(requestContext);

            //assert
            Assert.AreEqual("~/aspx/admin/foo.ashx", virtualPath);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:25,代码来源:DirectoryRouteHandlerTests.cs

示例2: GetRouteDataWithAnyRequest_ReturnsNull

        public void GetRouteDataWithAnyRequest_ReturnsNull()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new ImageRoute("{*anything}");

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            Assert.IsNull(routeData);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:13,代码来源:ImageRouteTests.cs

示例3: GetRouteData_MatchingTheImplicitSubfolderRoute_ReturnsParentDirectoryRoute

        public void GetRouteData_MatchingTheImplicitSubfolderRoute_ReturnsParentDirectoryRoute()
        {
            //arrange
            var route = new DirectoryRoute("dir", new Mock<IServiceLocator>().Object);
            ;
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/dir/foo.aspx");
            var blogRequest = new BlogRequest("localhost", "subfolder", new Uri("http://localhost"), false);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object, blogRequest);

            //assert
            Assert.AreEqual(route, routeData.Route);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:15,代码来源:DirectoryRouteTests.cs

示例4: GetRouteDataWithRequestForDefaultInSubfolder_WhenAggregationEnabled_MatchesRequestAndReturnsDtp

        public void GetRouteDataWithRequestForDefaultInSubfolder_WhenAggregationEnabled_MatchesRequestAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/default.aspx", "subfolder" /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:15,代码来源:RootRouteTests.cs

示例5: RequestUrlWithSingleDigitMonth_ForBlogPost_DoesNotMatchPageRoute

        public void RequestUrlWithSingleDigitMonth_ForBlogPost_DoesNotMatchPageRoute()
        {
            //arrange
            var routes = new RouteCollection();
            var subtextRoutes = new SubtextRouteMapper(routes, new Mock<IServiceLocator>().Object);
            Routes.RegisterRoutes(subtextRoutes);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/archive/2008/1/10/blog-post.aspx");

            //act
            RouteData routeData = routes.GetRouteData(httpContext.Object);

            //assert.
            Assert.IsNull(routeData);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:15,代码来源:RoutesTests.cs

示例6: RequestWithoutSubfolderForInstallDirectory_Matches

        public void RequestWithoutSubfolderForInstallDirectory_Matches()
        {
            //arrange
            var routes = new RouteCollection();
            var subtextRoutes = new SubtextRouteMapper(routes, new Mock<IServiceLocator>().Object);
            Routes.RegisterRoutes(subtextRoutes);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/install/default.aspx", "");

            //act
            RouteData routeData = routes.GetRouteData(httpContext.Object);

            //assert.
            Assert.IsNotNull(routeData);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:15,代码来源:RoutesTests.cs

示例7: GetRouteData_MatchingTheImplicitSubfolderRoute_ReturnsParentDirectoryRoute

        public void GetRouteData_MatchingTheImplicitSubfolderRoute_ReturnsParentDirectoryRoute()
        {
            //arrange
            var route = new PageRoute("url", "~/aspx/Dtp.aspx", new[] { "foo" }, new Mock<ISubtextPageBuilder>().Object,
                                      new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/subfolder/url");
            var blogRequest = new BlogRequest("localhost", "subfolder", new Uri("http://localhost"), false);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object, blogRequest);

            //assert
            Assert.AreEqual(route, routeData.Route);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:15,代码来源:PageRouteTests.cs

示例8: GetRouteDataWithRequestForAppRoot_WhenAggregationEnabled_MatchesAndReturnsAggDefault

        public void GetRouteDataWithRequestForAppRoot_WhenAggregationEnabled_MatchesAndReturnsAggDefault()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(true, new Mock<IDependencyResolver>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/AggDefault.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
            Assert.IsFalse(routeData.DataTokens.ContainsKey(STRouting.PageRoute.ControlNamesKey));
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:16,代码来源:RootRouteTests.cs

示例9: GetRouteDataWithRequestForAppRoot_WhenAggregationDisabled_MatchesAndReturnsDtp

        public void GetRouteDataWithRequestForAppRoot_WhenAggregationDisabled_MatchesAndReturnsDtp()
        {
            //arrange
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/", string.Empty /* subfolder */, "~/");
            var route = new STRouting.RootRoute(false, new Mock<IServiceLocator>().Object);

            //act
            RouteData routeData = route.GetRouteData(httpContext.Object);

            //assert
            var routeHandler = routeData.RouteHandler as STRouting.PageRouteHandler;
            Assert.AreEqual("~/aspx/Dtp.aspx", routeHandler.VirtualPath);
            Assert.AreSame(route, routeData.Route);
            Assert.IsTrue(routeData.DataTokens.ContainsKey(STRouting.PageRoute.ControlNamesKey));
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:16,代码来源:RootRouteTests.cs

示例10: GetRouteData_ForRequestForEntryAdminController_Matches

        public void GetRouteData_ForRequestForEntryAdminController_Matches()
        {
            //arrange
            var routes = new RouteCollection();
            var subtextRoutes = new SubtextRouteMapper(routes, new Mock<IDependencyResolver>().Object);
            Routes.RegisterRoutes(subtextRoutes);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/admin/comments/destroy.ashx", "");

            //act
            RouteData routeData = routes.GetRouteData(httpContext.Object);

            //assert.
            Assert.IsNotNull(routeData);
            Assert.AreEqual("comment", routeData.Values["controller"]);
            Assert.AreEqual("destroy", routeData.Values["action"]);
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:17,代码来源:RoutesTests.cs

示例11: GetRouteData_ForRequestForExportController_Matches

        public void GetRouteData_ForRequestForExportController_Matches()
        {
            //arrange
            var routes = new RouteCollection();
            var subtextRoutes = new SubtextRouteMapper(routes, new Mock<IServiceLocator>().Object);
            Routes.RegisterRoutes(subtextRoutes);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/admin/export.ashx", "");

            //act
            RouteData routeData = routes.GetRouteData(httpContext.Object);

            //assert.
            Assert.IsNotNull(routeData);
            Assert.AreEqual("export", routeData.Values["controller"]);
            Assert.AreEqual("blogml", routeData.Values["action"]);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:17,代码来源:RoutesTests.cs

示例12: GetVirtualPath_WithoutSubolder_ReturnsUrlWithoutSubfolder

        public void GetVirtualPath_WithoutSubolder_ReturnsUrlWithoutSubfolder()
        {
            //arrange
            var route = new PageRoute("archive/{slug}.aspx", "~/aspx/Dtp.aspx", null,
                                      new Mock<ISubtextPageBuilder>().Object, new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/archive/slug.aspx");
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);

            //act
            VirtualPathData virtualPath = route.GetVirtualPath(requestContext,
                                                               new RouteValueDictionary(new { slug = "test-slug" }));

            //assert
            Assert.IsNotNull(virtualPath);
            Assert.AreEqual("archive/test-slug.aspx", virtualPath.VirtualPath);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:18,代码来源:PageRouteTests.cs

示例13: RequestWithoutSubfolder_ForBlogPostWithoutSubfolder_Matches

        public void RequestWithoutSubfolder_ForBlogPostWithoutSubfolder_Matches()
        {
            //arrange
            var subtextRoute = new PageRoute("archive/{slug}", "~/aspx/Dtp.aspx", null,
                                             new Mock<ISubtextPageBuilder>().Object, new Mock<IDependencyResolver>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/archive/blog-post");
            //This info is provided by the BlogRequestModule.
            var blogRequest = new BlogRequest("localhost", string.Empty, new Uri("http://localhost/archive/blog-post"),
                                              true);

            //act
            RouteData routeData = subtextRoute.GetRouteData(httpContext.Object, blogRequest);

            //assert.
            Assert.IsNotNull(routeData);
            Assert.AreEqual("blog-post", routeData.Values["slug"]);
            Assert.AreEqual(string.Empty, routeData.Values["subfolder"]);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:19,代码来源:PageRouteTests.cs

示例14: GetVirtualPath_WithoutSubolder_ReturnsUrlWithoutSubfolder

        public void GetVirtualPath_WithoutSubolder_ReturnsUrlWithoutSubfolder()
        {
            //arrange
            var route = new DirectoryRoute("admin", new Mock<IServiceLocator>().Object);
            var httpContext = new Mock<HttpContextBase>();
            httpContext.FakeRequest("~/admin/posts/foo.aspx");
            var blogRequest = new BlogRequest("localhost", null, new Uri("http://localhost"), true);
            var routeData = new RouteData();
            var requestContext = new RequestContext(httpContext.Object, routeData);

            //act
            VirtualPathData virtualPath = route.GetVirtualPath(requestContext
                                                               ,
                                                               new RouteValueDictionary(
                                                                   new {pathInfo = "posts/foo.aspx"}));

            //assert
            Assert.IsNotNull(virtualPath);
            Assert.AreEqual("admin/posts/foo.aspx", virtualPath.VirtualPath);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:20,代码来源:DirectoryRouteTests.cs

示例15: FakeSubtextContextRequest

        public static StringWriter FakeSubtextContextRequest(this Mock<ISubtextContext> subtextContextMock, Blog blog,
            string virtualPath, string applicationPath,
            string subfolder)
        {
            var httpContext = new Mock<HttpContextBase>();
            StringWriter writer = httpContext.FakeRequest(virtualPath, subfolder);
            httpContext.SetupApplicationPath(applicationPath);
            httpContext.Stub(h => h.Response.ContentType);
            var hashTable = new Hashtable();
            httpContext.Setup(c => c.Items).Returns(hashTable);
            var urlHelper = new Mock<BlogUrlHelper>();

            var routeData = new RouteData();
            routeData.Values.Add("subfolder", subfolder);

            subtextContextMock.Setup(c => c.HttpContext).Returns(httpContext.Object);

            subtextContextMock.SetupBlog(blog)
                .SetupUrlHelper(urlHelper)
                .SetupRequestContext(httpContext, routeData);

            return writer;
        }
开发者ID:rhoadsce,项目名称:Subtext,代码行数:23,代码来源:MockExtensions.cs


注:本文中的Mock.FakeRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。