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


C# TestableVirtualPathProviderViewEngine.FindView方法代码示例

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


在下文中一共展示了TestableVirtualPathProviderViewEngine.FindView方法的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: 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

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

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

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

            // Assert
            Assert.Null(result.View);
            Assert.Single(result.SearchedLocations);
            Assert.True(result.SearchedLocations.Contains("/foo/bar.unsupported"));
            engine.MockPathProvider.Verify(vpp => vpp.FileExists("/foo/bar.unsupported"), Times.Never());
            engine.MockCache.Verify();
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:19,代码来源:VirtualPathProviderViewEngineTest.cs

示例8: NoValueInCacheButFileExistsReturnsNullIfUsingCache

        public void NoValueInCacheButFileExistsReturnsNullIfUsingCache()
        {
            // Arrange
            ControllerContext mobileContext = CreateContext(isMobileDevice: true);
            TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();

            engine.MockPathProvider
                .Setup(vpp => vpp.FileExists(MOBILE_VIEW_VIRTUAL))
                .Returns(true);
            engine.MockPathProvider
                .Setup(vpp => vpp.FileExists(VIEW_VIRTUAL))
                .Returns(true);

            engine.MockCache
                .Setup(c => c.GetViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>()))
                .Returns((string)null)
                .Verifiable();
            engine.MockCache
                .Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), It.IsAny<string>()));

            // Act
            IView viewNotInCacheResult = engine.FindView(mobileContext, "name", masterName: null, useCache: true).View;

            // Assert
            Assert.Null(viewNotInCacheResult);

            // On a cache miss we should never check the file system. FindView will be called on a second pass
            // without using the cache.
            engine.MockPathProvider.Verify(vpp => vpp.FileExists(MOBILE_VIEW_VIRTUAL), Times.Never());
            engine.MockPathProvider.Verify(vpp => vpp.FileExists(VIEW_VIRTUAL), Times.Never());

            // Act & Assert

            //At this point the view on disk should be found and cached.
            Assert.NotNull(engine.FindView(mobileContext, "name", masterName: null, useCache: false).View);
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:36,代码来源:VirtualPathProviderViewEngineTest.cs

示例9: FindView_VirtualPathViewDoesNotExistAndNoMaster_ReturnsSearchedLocationsResult

        public void FindView_VirtualPathViewDoesNotExistAndNoMaster_ReturnsSearchedLocationsResult() {
            // Arrange
            ControllerContext context = CreateContext();
            TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
            engine.MockPathProvider
                .Setup(vpp => vpp.FileExists("~/foo/bar.view"))
                .Returns(false)
                .Verifiable();
            engine.MockCache
                .Setup(c => c.InsertViewLocation(It.IsAny<HttpContextBase>(), It.IsAny<string>(), ""))
                .Verifiable();

            // Act
            ViewEngineResult result = engine.FindView(context, "~/foo/bar.view", null, false);

            // Assert
            Assert.IsNull(result.View);
            Assert.AreEqual(1, result.SearchedLocations.Count());
            Assert.IsTrue(result.SearchedLocations.Contains("~/foo/bar.view"));
            engine.MockPathProvider.Verify();
            engine.MockCache.Verify();
        }
开发者ID:adrianvallejo,项目名称:MVC3_Source,代码行数:22,代码来源:VirtualPathProviderViewEngineTest.cs

示例10: FindView_ViewDoesNotExistAndNoMaster_ReturnsSearchedLocationsResult

        public void FindView_ViewDoesNotExistAndNoMaster_ReturnsSearchedLocationsResult()
        {
            // Arrange
            ControllerContext context = CreateContext();
            TestableVirtualPathProviderViewEngine engine = new TestableVirtualPathProviderViewEngine();
            engine.MockPathProvider
                .Setup(vpp => vpp.FileExists("~/vpath/controllerName/viewName.view"))
                .Returns(false)
                .Verifiable();

            // Act
            ViewEngineResult result = engine.FindView(context, "viewName", null, false);

            // Assert
            Assert.Null(result.View);
            Assert.Single(result.SearchedLocations);
            Assert.True(result.SearchedLocations.Contains("~/vpath/controllerName/viewName.view"));
            engine.MockPathProvider.Verify();
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:19,代码来源:VirtualPathProviderViewEngineTest.cs

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

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

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

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

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


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