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


C# TestableVirtualPathProviderViewEngine.ClearMasterLocations方法代码示例

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


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

示例1: 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

示例2: 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

示例3: FindView_AbsolutePathViewExistsAndNoMaster_Legacy_ReturnsView

        public void FindView_AbsolutePathViewExistsAndNoMaster_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.ClearMasterLocations();
            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.FindView(context, "/foo/bar.unsupported", null, false);

            // Assert
            Assert.Same(engine.CreateViewResult, result.View);
            Assert.Null(result.SearchedLocations);
            Assert.Same(context, engine.CreateViewControllerContext);
            Assert.Equal("/foo/bar.unsupported", engine.CreateViewViewPath);
            Assert.Equal(String.Empty, engine.CreateViewMasterPath);
            engine.MockPathProvider.Verify();
            engine.MockCache.Verify();
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:29,代码来源:VirtualPathProviderViewEngineTest.cs

示例4: 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


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