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


C# TestableVirtualPathProviderViewEngine类代码示例

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


TestableVirtualPathProviderViewEngine类属于命名空间,在下文中一共展示了TestableVirtualPathProviderViewEngine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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