本文整理汇总了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");
}
示例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);
}
示例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>()));
}
示例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));
}
示例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");
}
示例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>()));
}