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


C# Mock.Never方法代码示例

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


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

示例1: GetRouteData_Calls_All_Routes_After_Prerouter

        public void GetRouteData_Calls_All_Routes_After_Prerouter()
        {
            // Arrange
            RouteData expectedRouteData = new RouteData();

            var mockRoute1 = new Mock<RouteBase>();
            var mockRoute2 = new Mock<RouteBase>();

            mockRoute1.Never(r => r.GetRouteData(It.IsAny<HttpContextBase>()));
            mockRoute2.Setup(r => r.GetRouteData(It.IsAny<HttpContextBase>()))
                      .Returns(expectedRouteData);

            PortalVirtualizationPrerouter router = CreateRouterWithMockData();
            RouteCollection fakeRoutes = new RouteCollection {
                {"NextRoute", mockRoute1.Object},
                {"Prerouter", router},
                {"AnotherRoute", mockRoute2.Object}
            };

            HttpContextBase httpContext = Mockery.CreateMockHttpContext("http://localhost/Foo/Bar/Qux?id=43234&a=234#foo");
            router.RouteCollection = fakeRoutes;

            // Act
            RouteData actualRouteData = router.GetRouteData(httpContext);

            // Assert
            mockRoute2.Verify(r => r.GetRouteData(It.IsAny<HttpContextBase>()));
            Assert.AreEqual(expectedRouteData, actualRouteData, "Expected that the first non-null return value from the other routes would be returned");
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:29,代码来源:PortalVirtualizationPrerouterTests.cs

示例2: GetCurrentDataContext_Returns_DataContext_In_HttpContext_If_Present

        public void GetCurrentDataContext_Returns_DataContext_In_HttpContext_If_Present()
        {
            // Arrange
            HttpContextDataContextManager manager = new HttpContextDataContextManager();

            HttpContextBase context = Mockery.CreateMockHttpContext();
            manager.HttpContextSource = () => context;

            DataContext expectedDataContext = new Mock<DataContext>().Object;
            context.Items[HttpContextDataContextManager.ContextKey] = expectedDataContext;

            var mockDataContextBuilder = new Mock<DataContextBuilder>();
            mockDataContextBuilder.Never(b => b.CreateDataContext());
            manager.DataContextBuilder = mockDataContextBuilder.Object;

            // Act
            DataContext actualDataContext = manager.GetCurrentDataContext();

            // Assert
            Assert.AreSame(expectedDataContext, actualDataContext);
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:21,代码来源:HttpContextDataContextManagerTests.cs

示例3: GetRouteData_Calls_All_Routes_After_Prerouter

        public void GetRouteData_Calls_All_Routes_After_Prerouter()
        {
            // Arrange
            HttpContextBase httpContext = CreateMockHttpContext("~/Foo/Baz/Bar/Zoop/Zork/Zoink");

            var mockRoute1 = new Mock<RouteBase>();
            var mockRoute2 = new Mock<RouteBase>();

            mockRoute1.Never(r => r.GetRouteData(It.IsAny<HttpContextBase>()));

            PagePrerouter router = CreateRouterWithMockData();
            router.RouteCollection = new RouteCollection {
                {"FirstRoute", mockRoute1.Object},
                {"Prerouter", router},
                {"NextRoute", mockRoute2.Object}
            };

            // Act
            RouteData routeData = router.GetRouteData(httpContext);

            // Assert
            mockRoute2.Verify(r => r.GetRouteData(It.IsAny<HttpContextBase>()));
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:23,代码来源:PagePrerouterTests.cs

示例4: GetVirtualPath_Calls_All_Other_Routes_To_Route_Request

        public void GetVirtualPath_Calls_All_Other_Routes_To_Route_Request()
        {
            // Arrange
            HttpContextBase httpContext = Mockery.CreateMockHttpContext("http://localhost/Foo/Bar/Qux?id=43234&a=234");
            SetActivePortalPrefix(httpContext, "localhost/Foo/Bar/Qux");
            SetMockApplicationPath(httpContext, "/Foo");

            var mockRoute1 = new Mock<RouteBase>();
            var mockRoute2 = new Mock<RouteBase>();

            mockRoute1.Never(r => r.GetVirtualPath(It.IsAny<RequestContext>(), It.IsAny<RouteValueDictionary>()));

            PortalVirtualizationPrerouter router = CreateRouterWithMockData();
            RouteCollection fakeRoutes = new RouteCollection {
                {"FirstRoute", mockRoute1.Object},
                {"Prerouter", router},
                {"NextRoute", mockRoute2.Object}
            };

            router.RouteCollection = fakeRoutes;

            // Act
            RequestContext expectedRequestContext = new RequestContext(httpContext, new RouteData());
            RouteValueDictionary expectedValues = new RouteValueDictionary();
            router.GetVirtualPath(expectedRequestContext,
                                  expectedValues);

            // Assert
            mockRoute2.Verify(r => r.GetVirtualPath(expectedRequestContext, expectedValues));
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:30,代码来源:PortalVirtualizationPrerouterTests.cs

示例5: GetVirtualPath_Returns_Null_If_Null_Page_Present_In_Values

        public void GetVirtualPath_Returns_Null_If_Null_Page_Present_In_Values()
        {
            // Arrange
            var mockRoute = new Mock<RouteBase>();

            mockRoute.Never(r => r.GetVirtualPath(It.IsAny<RequestContext>(), It.IsAny<RouteValueDictionary>()));

            PagePrerouter router = new PagePrerouter();
            router.RouteCollection = new RouteCollection {
                {"Prerouter", router},
                {"NextRoute", mockRoute.Object}
            };

            HttpContextBase httpContext = CreateMockHttpContext("~/Foo/Bar/Baz");
            RouteValueDictionary values = new RouteValueDictionary(new {page = (Page)null});

            // Act
            VirtualPathData pathData = router.GetVirtualPath(new RequestContext(httpContext, new RouteData()), values);

            // Assert
            Assert.IsNull(pathData, "Expected that the prerouter would be bypassed");
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:22,代码来源:PagePrerouterTests.cs

示例6: GetVirtualPath_Calls_All_Routes_After_Prerouter

        public void GetVirtualPath_Calls_All_Routes_After_Prerouter()
        {
            // Arrange
            var mockRoute1 = new Mock<RouteBase>();
            var mockRoute2 = new Mock<RouteBase>();

            mockRoute1.Never(r => r.GetVirtualPath(It.IsAny<RequestContext>(), It.IsAny<RouteValueDictionary>()));

            PagePrerouter router = new PagePrerouter();
            router.RouteCollection = new RouteCollection {
                {"FirstRoute", mockRoute1.Object},
                {"Prerouter", router},
                {"NextRoute", mockRoute2.Object}
            };

            HttpContextBase httpContext = CreateMockHttpContext("~/Foo/Bar/Baz");
            httpContext.GetPortalContext().ActivePage = new Page {Id = 4, Path = "/"};

            // Act
            VirtualPathData pathData = router.GetVirtualPath(new RequestContext(httpContext, new RouteData()),
                                                             new RouteValueDictionary());
            // Assert
            mockRoute2.Verify(r => r.GetVirtualPath(It.IsAny<RequestContext>(), It.IsAny<RouteValueDictionary>()));
        }
开发者ID:anurse,项目名称:MaVeriCk,代码行数:24,代码来源:PagePrerouterTests.cs


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