本文整理汇总了C#中TestableVirtualPathProviderViewEngine类的典型用法代码示例。如果您正苦于以下问题:C# TestableVirtualPathProviderViewEngine类的具体用法?C# TestableVirtualPathProviderViewEngine怎么用?C# TestableVirtualPathProviderViewEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestableVirtualPathProviderViewEngine类属于命名空间,在下文中一共展示了TestableVirtualPathProviderViewEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindViewWithNullControllerContextThrows
public void FindViewWithNullControllerContextThrows() {
// Arrange
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
// Act & Assert
ExceptionHelper.ExpectArgumentNullException(
() => engine.FindView(null, "view name", null, false),
"controllerContext"
);
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:10,代码来源:VirtualPathProviderViewEngineTest.cs
示例2: FindViewWithEmptyViewNameThrows
public void FindViewWithEmptyViewNameThrows() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
// Act & Assert
ExceptionHelper.ExpectArgumentExceptionNullOrEmpty(
() => engine.FindView(context, "", null, false),
"viewName"
);
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:11,代码来源:VirtualPathProviderViewEngineTest.cs
示例3: FindView_NullControllerContext_Throws
public void FindView_NullControllerContext_Throws()
{
// Arrange
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
// Act & Assert
Assert.ThrowsArgumentNull(
() => engine.FindView(null, "view name", null, false),
"controllerContext"
);
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:11,代码来源:VirtualPathProviderViewEngineTest.cs
示例4: FindViewViewLocationsCannotBeEmpty
public void FindViewViewLocationsCannotBeEmpty() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.ClearViewLocations();
// Act & Assert
ExceptionHelper.ExpectInvalidOperationException(
() => engine.FindView(context, "viewName", null, false),
"The property 'ViewLocationFormats' cannot be null or empty."
);
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:12,代码来源:VirtualPathProviderViewEngineTest.cs
示例5: FindViewControllerNameMustExistInRequestContext
public void FindViewControllerNameMustExistInRequestContext() {
// Arrange
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
ControllerContext context = CreateContext();
context.RouteData.Values.Remove("controller");
// Act & Assert
ExceptionHelper.ExpectInvalidOperationException(
() => engine.FindView(context, "viewName", null, false),
"The RouteData must contain an item named 'controller' with a non-empty string value."
);
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:12,代码来源:VirtualPathProviderViewEngineTest.cs
示例6: FindView_EmptyViewName_Throws
public void FindView_EmptyViewName_Throws()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
// Act & Assert
Assert.ThrowsArgumentNullOrEmpty(
() => engine.FindView(context, "", null, false),
"viewName"
);
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:12,代码来源:VirtualPathProviderViewEngineTest.cs
示例7: CannotFindViewNoMaster
public void CannotFindViewNoMaster() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Expect(vpp => vpp.FileExists("~/vpath/controllerName/viewName.view"))
.Returns(false)
.Verifiable();
// Act
ViewEngineResult result = engine.FindView(context, "viewName", null, false);
// Assert
Assert.IsNull(result.View);
Assert.AreEqual(1, result.SearchedLocations.Count());
Assert.IsTrue(result.SearchedLocations.Contains("~/vpath/controllerName/viewName.view"));
engine.MockPathProvider.Verify();
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:18,代码来源:VirtualPathProviderViewEngineTest.cs
示例8: FoundViewCannotFindMaster
public void FoundViewCannotFindMaster() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Expect(vpp => vpp.FileExists("~/vpath/controllerName/viewName.view"))
.Returns(true)
.Verifiable();
engine.MockCache
.Expect(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/vpath/controllerName/viewName.view"))
.Verifiable();
engine.MockPathProvider
.Expect(vpp => vpp.FileExists("~/vpath/controllerName/masterName.master"))
.Returns(false)
.Verifiable();
// Act
ViewEngineResult result = engine.FindView(context, "viewName", "masterName", false);
// Assert
Assert.IsNull(result.View);
Assert.AreEqual(1, result.SearchedLocations.Count()); // View was found, not included in 'searched locations'
Assert.IsTrue(result.SearchedLocations.Contains("~/vpath/controllerName/masterName.master"));
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:26,代码来源:VirtualPathProviderViewEngineTest.cs
示例9: FindView_VirtualPathViewExistsAndNoMaster_ReturnsView
public void FindView_VirtualPathViewExistsAndNoMaster_ReturnsView()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.ClearMasterLocations();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/foo/bar.view"))
.Returns(true)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/foo/bar.view"))
.Verifiable();
// Act
ViewEngineResult result = engine.FindView(context, "~/foo/bar.view", null, false);
// Assert
Assert.Same(engine.CreateViewResult, result.View);
Assert.Null(result.SearchedLocations);
Assert.Same(context, engine.CreateViewControllerContext);
Assert.Equal("~/foo/bar.view", engine.CreateViewViewPath);
Assert.Equal(String.Empty, engine.CreateViewMasterPath);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:26,代码来源:VirtualPathProviderViewEngineTest.cs
示例10: FindPartialView_AbsolutePathViewExists_ReturnsView
public void FindPartialView_AbsolutePathViewExists_ReturnsView()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("/foo/bar.partial"))
.Returns(true)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "/foo/bar.partial"))
.Verifiable();
// Act
ViewEngineResult result = engine.FindPartialView(context, "/foo/bar.partial", false);
// Assert
Assert.Same(engine.CreatePartialViewResult, result.View);
Assert.Null(result.SearchedLocations);
Assert.Same(context, engine.CreatePartialViewControllerContext);
Assert.Equal("/foo/bar.partial", engine.CreatePartialViewPartialPath);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:24,代码来源:VirtualPathProviderViewEngineTest.cs
示例11: FindPartialView_ViewDoesNotExist_ReturnsSearchLocationsResult
public void FindPartialView_ViewDoesNotExist_ReturnsSearchLocationsResult() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/partialName.partial"))
.Returns(false)
.Verifiable();
// Act
ViewEngineResult result = engine.FindPartialView(context, "partialName", false);
// Assert
Assert.IsNull(result.View);
Assert.AreEqual(1, result.SearchedLocations.Count());
Assert.IsTrue(result.SearchedLocations.Contains("~/vpath/controllerName/partialName.partial"));
engine.MockPathProvider.Verify();
}
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:18,代码来源:VirtualPathProviderViewEngineTest.cs
示例12: FindPartialView_VirtualPathViewExists_Legacy_ReturnsView
public void FindPartialView_VirtualPathViewExists_Legacy_ReturnsView()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine()
{
FileExtensions = null, // Set FileExtensions to null to simulate View Engines that do not set this property
};
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/foo/bar.unsupported"))
.Returns(true)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/foo/bar.unsupported"))
.Verifiable();
// Act
ViewEngineResult result = engine.FindPartialView(context, "~/foo/bar.unsupported", false);
// Assert
Assert.Same(engine.CreatePartialViewResult, result.View);
Assert.Null(result.SearchedLocations);
Assert.Same(context, engine.CreatePartialViewControllerContext);
Assert.Equal("~/foo/bar.unsupported", engine.CreatePartialViewPartialPath);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:27,代码来源:VirtualPathProviderViewEngineTest.cs
示例13: FindPartialView_AbsolutePathViewNotSupported_ReturnsSearchedLocationsResult
public void FindPartialView_AbsolutePathViewNotSupported_ReturnsSearchedLocationsResult()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), ""))
.Verifiable();
// Act
ViewEngineResult result = engine.FindPartialView(context, "/foo/bar.unsupported", false);
// Assert
Assert.Null(result.View);
Assert.Single(result.SearchedLocations);
Assert.True(result.SearchedLocations.Contains("/foo/bar.unsupported"));
engine.MockPathProvider.Verify<bool>(vpp => vpp.FileExists("/foo/bar.unsupported"), Times.Never());
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:19,代码来源:VirtualPathProviderViewEngineTest.cs
示例14: FindPartialView_ControllerNameNotInRequestContext_Throws
public void FindPartialView_ControllerNameNotInRequestContext_Throws()
{
// Arrange
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
ControllerContext context = CreateContext();
context.RouteData.Values.Remove("controller");
// Act & Assert
Assert.Throws<InvalidOperationException>(
() => engine.FindPartialView(context, "partialName", false),
"The RouteData must contain an item named 'controller' with a non-empty string value."
);
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:13,代码来源:VirtualPathProviderViewEngineTest.cs
示例15: FindView_MasterInAreaDoesNotExist_ReturnsSearchedLocationsResult
public void FindView_MasterInAreaDoesNotExist_ReturnsSearchedLocationsResult()
{
// Arrange
ControllerContext context = CreateContext();
context.RouteData.DataTokens["area"] = "areaName";
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/areaName/controllerName/viewName.view"))
.Returns(true)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/vpath/areaName/controllerName/viewName.view"))
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/areaName/controllerName/viewName.Mobile.view"))
.Returns(false)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/areaName/controllerName/masterName.master"))
.Returns(false)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/masterName.master"))
.Returns(false)
.Verifiable();
// Act
ViewEngineResult result = engine.FindView(context, "viewName", "masterName", false);
// Assert
Assert.Null(result.View);
Assert.Equal(2, result.SearchedLocations.Count()); // View was found, not included in 'searched locations'
Assert.True(result.SearchedLocations.Contains("~/vpath/areaName/controllerName/masterName.master"));
Assert.True(result.SearchedLocations.Contains("~/vpath/controllerName/masterName.master"));
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:38,代码来源:VirtualPathProviderViewEngineTest.cs
示例16: FindView_ViewExistsAndMasterNameProvidedButEmptyMasterLocations_Throws
public void FindView_ViewExistsAndMasterNameProvidedButEmptyMasterLocations_Throws()
{
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.ClearMasterLocations();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/viewName.view"))
.Returns(true)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/vpath/controllerName/viewName.view"))
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/viewName.Mobile.view"))
.Returns(false)
.Verifiable();
// Act & Assert
Assert.Throws<InvalidOperationException>(
() => engine.FindView(context, "viewName", "masterName", false),
"The property 'MasterLocationFormats' cannot be null or empty."
);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:26,代码来源:VirtualPathProviderViewEngineTest.cs
示例17: ViewFound
public void ViewFound() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Expect(vpp => vpp.FileExists("~/vpath/controllerName/partialName.partial"))
.Returns(true)
.Verifiable();
engine.MockCache
.Expect(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/vpath/controllerName/partialName.partial"))
.Verifiable();
// Act
ViewEngineResult result = engine.FindPartialView(context, "partialName", false);
// Assert
Assert.AreSame(engine.CreatePartialViewResult, result.View);
Assert.IsNull(result.SearchedLocations);
Assert.AreSame(context, engine.CreatePartialViewControllerContext);
Assert.AreEqual("~/vpath/controllerName/partialName.partial", engine.CreatePartialViewPartialPath);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:23,代码来源:VirtualPathProviderViewEngineTest.cs
示例18: ValueInCacheBypassesVirtualPathProvider
public void ValueInCacheBypassesVirtualPathProvider() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider // It wasn't found, so they call vpp.FileExists
.Expect(vpp => vpp.FileExists(VIEW_VIRTUAL))
.Returns(true)
.AtMostOnce()
.Verifiable();
engine.MockCache // Then they set the value into the cache
.Expect(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), VIEW_VIRTUAL))
.Callback<HttpContextBase, string, string>((httpContext, key, virtualPath) => {
engine.MockCache // Second time through, we give them a cache hit
.Expect(c => c.GetViewLocation(It.IsAny<HttpContextBase>(), key))
.Returns(VIEW_VIRTUAL)
.AtMostOnce()
.Verifiable();
})
.AtMostOnce()
.Verifiable();
// Act
engine.FindView(context, "name", null, false); // Call it once with false to seed the cache
engine.FindView(context, "name", null, true); // Call it once with true to check the cache
// Assert
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:30,代码来源:VirtualPathProviderViewEngineTest.cs
示例19: ViewFoundNoMaster
public void ViewFoundNoMaster() {
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.ClearMasterLocations(); // If master is not provided, master locations can be empty
engine.MockPathProvider
.Expect(vpp => vpp.FileExists("~/vpath/controllerName/viewName.view"))
.Returns(true)
.Verifiable();
engine.MockCache
.Expect(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), "~/vpath/controllerName/viewName.view"))
.Verifiable();
// Act
ViewEngineResult result = engine.FindView(context, "viewName", null, false);
// Assert
Assert.AreSame(engine.CreateViewResult, result.View);
Assert.IsNull(result.SearchedLocations);
Assert.AreSame(context, engine.CreateViewControllerContext);
Assert.AreEqual("~/vpath/controllerName/viewName.view", engine.CreateViewViewPath);
Assert.AreEqual(String.Empty, engine.CreateViewMasterPath);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
}
开发者ID:pruiz,项目名称:AspMvc2,代码行数:25,代码来源:VirtualPathProviderViewEngineTest.cs
示例20: UsesDifferentKeysForViewMasterAndPartial
public void UsesDifferentKeysForViewMasterAndPartial()
{
string keyMaster = null;
string keyPartial = null;
string keyView = null;
// Arrange
ControllerContext context = CreateContext();
TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists(VIEW_VIRTUAL))
.Returns(true)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists(MOBILE_VIEW_VIRTUAL))
.Returns(false)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists(MASTER_VIRTUAL))
.Returns(true)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/name.Mobile.master"))
.Returns(false)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists(PARTIAL_VIRTUAL))
.Returns(true)
.Verifiable();
engine.MockPathProvider
.Setup(vpp => vpp.FileExists("~/vpath/controllerName/name.Mobile.partial"))
.Returns(false)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), VIEW_VIRTUAL))
.Callback<HttpContextBase, string, string>((httpContext, key, path) => keyView = key)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), MASTER_VIRTUAL))
.Callback<HttpContextBase, string, string>((httpContext, key, path) => keyMaster = key)
.Verifiable();
engine.MockCache
.Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), PARTIAL_VIRTUAL))
.Callback<HttpContextBase, string, string>((httpContext, key, path) => keyPartial = key)
.Verifiable();
// Act
engine.FindView(context, "name", "name", false);
engine.FindPartialView(context, "name", false);
// Assert
Assert.NotNull(keyMaster);
Assert.NotNull(keyPartial);
Assert.NotNull(keyView);
Assert.NotEqual(keyMaster, keyPartial);
Assert.NotEqual(keyMaster, keyView);
Assert.NotEqual(keyPartial, keyView);
engine.MockPathProvider.Verify();
engine.MockCache.Verify();
engine.MockPathProvider
.Verify(vpp => vpp.FileExists(VIEW_VIRTUAL), Times.AtMostOnce());
engine.MockPathProvider
.Verify(vpp => vpp.FileExists(MASTER_VIRTUAL), Times.AtMostOnce());
engine.MockPathProvider
.Verify(vpp => vpp.FileExists(PARTIAL_VIRTUAL), Times.AtMostOnce());
engine.MockCache
.Verify(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), VIEW_VIRTUAL), Times.AtMostOnce());
engine.MockCache
.Verify(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), MASTER_VIRTUAL), Times.AtMostOnce());
engine.MockCache
.Verify(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), PARTIAL_VIRTUAL), Times.AtMostOnce());
}
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:72,代码来源:VirtualPathProviderViewEngineTest.cs
注:本文中的TestableVirtualPathProviderViewEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论