當前位置: 首頁>>代碼示例>>C#>>正文


C# Test.MockBuildManager類代碼示例

本文整理匯總了C#中System.Web.Mvc.Test.MockBuildManager的典型用法代碼示例。如果您正苦於以下問題:C# MockBuildManager類的具體用法?C# MockBuildManager怎麽用?C# MockBuildManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MockBuildManager類屬於System.Web.Mvc.Test命名空間,在下文中一共展示了MockBuildManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildManagerProperty

        public void BuildManagerProperty() {
            // Arrange
            TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
            MockBuildManager buildManagerMock = new MockBuildManager(null, null, null);

            // Act
            engine.BuildManager = buildManagerMock;

            // Assert
            Assert.AreEqual(engine.BuildManager, buildManagerMock);
        }
開發者ID:Marceli,項目名稱:JQueryGridTest,代碼行數:11,代碼來源:WebFormViewEngineTest.cs

示例2: BuildManagerProperty

        public void BuildManagerProperty() {
            // Arrange
            var engine = new TestableBuildManagerViewEngine();
            var buildManagerMock = new MockBuildManager(expectedVirtualPath: null, compiledType: null);

            // Act
            engine.BuildManager = buildManagerMock;

            // Assert
            Assert.AreSame(engine.BuildManager, buildManagerMock);
        }
開發者ID:adrianvallejo,項目名稱:MVC3_Source,代碼行數:11,代碼來源:BuildManagerViewEngineTest.cs

示例3: FileExistsReturnsFalseWhenBuildManagerFileExistsReturnsFalse

        public void FileExistsReturnsFalseWhenBuildManagerFileExistsReturnsFalse() {
            // Arrange
            var engine = new TestableBuildManagerViewEngine();
            var buildManagerMock = new MockBuildManager("some path", false);
            engine.BuildManager = buildManagerMock;

            // Act
            bool result = engine.FileExists("some path");

            // Assert
            Assert.IsFalse(result);
        }
開發者ID:adrianvallejo,項目名稱:MVC3_Source,代碼行數:12,代碼來源:BuildManagerViewEngineTest.cs

示例4: FileExistsReturnsTrueForExistingPath

        public void FileExistsReturnsTrueForExistingPath() {
            // Arrange
            var engine = new TestableBuildManagerViewEngine();
            var buildManagerMock = new MockBuildManager("some path", typeof(object));
            engine.BuildManager = buildManagerMock;

            // Act
            bool result = engine.FileExists("some path");

            // Assert
            Assert.IsTrue(result);
        }
開發者ID:adrianvallejo,項目名稱:MVC3_Source,代碼行數:12,代碼來源:BuildManagerViewEngineTest.cs

示例5: RegisterAllAreas

        public void RegisterAllAreas() {
            // Arrange
            string[] expectedLoadedAreas = new string[] { "AreaRegistrationTest_AreaRegistration" };
            AnnotatedRouteCollection routes = new AnnotatedRouteCollection();
            MockBuildManager buildManager = new MockBuildManager(new Assembly[] { typeof(AreaRegistrationTest).Assembly });

            // Act
            AreaRegistration.RegisterAllAreas(routes, buildManager, null);

            // Assert
            CollectionAssert.AreEquivalent(expectedLoadedAreas, routes._areasLoaded);
        }
開發者ID:jesshaw,項目名稱:ASP.NET-Mvc-3,代碼行數:12,代碼來源:AreaRegistrationTest.cs

示例6: FileExistsReturnsFalseWhenBuildManagerReturnsNull

        public void FileExistsReturnsFalseWhenBuildManagerReturnsNull() {
            // Arrange
            TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
            MockBuildManager buildManagerMock = new MockBuildManager("some path", typeof(object), null);
            engine.BuildManager = buildManagerMock;

            // Act
            bool notFoundResult = engine.PublicFileExists(null, "some path");

            // Assert
            Assert.IsFalse(notFoundResult);
        }
開發者ID:Marceli,項目名稱:JQueryGridTest,代碼行數:12,代碼來源:WebFormViewEngineTest.cs

示例7: RenderWithNullViewInstanceThrows

        public void RenderWithNullViewInstanceThrows() {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            MockBuildManager buildManager = new MockBuildManager("view path", compiledType: null);
            TestableBuildManagerCompiledView view = new TestableBuildManagerCompiledView(new ControllerContext(), "view path");
            view.BuildManager = buildManager;

            // Act & Assert
            ExceptionHelper.ExpectException<InvalidOperationException>(
                () => view.Render(context, new Mock<TextWriter>().Object),
                "The view found at 'view path' was not created."
            );
        }
開發者ID:jesshaw,項目名稱:ASP.NET-Mvc-3,代碼行數:13,代碼來源:BuildManagerCompiledViewTest.cs

示例8: FileExistsReturnsTrueForExistingPath

        public void FileExistsReturnsTrueForExistingPath() {
            // Arrange
            TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
            object instanceResult = new object();
            MockBuildManager buildManagerMock = new MockBuildManager("some path", typeof(object), instanceResult);
            engine.BuildManager = buildManagerMock;

            // Act
            bool foundResult = engine.PublicFileExists(null, "some path");

            // Assert
            Assert.IsTrue(foundResult);
        }
開發者ID:Marceli,項目名稱:JQueryGridTest,代碼行數:13,代碼來源:WebFormViewEngineTest.cs

示例9: RenderWithUnsupportedTypeThrows

        public void RenderWithUnsupportedTypeThrows() {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(object), 12345);
            WebFormView view = new WebFormView("view path", null);
            view.BuildManager = buildManagerMock;

            // Act & Assert
            ExceptionHelper.ExpectException<InvalidOperationException>(
                () => view.Render(context, null),
                "The view at 'view path' must derive from ViewPage, ViewPage<TViewData>, ViewUserControl, or ViewUserControl<TViewData>."
            );
        }
開發者ID:ledgarl,項目名稱:Samples,代碼行數:13,代碼來源:WebFormViewTest.cs

示例10: RenderWithNullViewInstanceThrows

        public void RenderWithNullViewInstanceThrows() {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            MockBuildManager buildManager = new MockBuildManager("view path", typeof(object), null);
            WebFormView view = new WebFormView("view path", null);
            view.BuildManager = buildManager;

            // Act & Assert
            ExceptionHelper.ExpectException<InvalidOperationException>(
                () => view.Render(context, null),
                "The view found at 'view path' could not be created."
            );
        }
開發者ID:ledgarl,項目名稱:Samples,代碼行數:13,代碼來源:WebFormViewTest.cs

示例11: FileExistsReturnsFalseWhenBuildManagerThrows404

        public void FileExistsReturnsFalseWhenBuildManagerThrows404() {
            // Arrange
            TestableWebFormViewEngine engine = new TestableWebFormViewEngine();
            object instanceResult = new object();
            MockBuildManager buildManagerMock = new MockBuildManager(new HttpException(404, "HTTP message Not Found"));
            engine.BuildManager = buildManagerMock;

            // Act
            bool notFoundResult = engine.PublicFileExists(null, "some other path");

            // Assert
            Assert.IsFalse(notFoundResult);
        }
開發者ID:sanyaade-mobiledev,項目名稱:ASP.NET-Mvc-2,代碼行數:13,代碼來源:WebFormViewEngineTest.cs

示例12: RenderWithNullWriterThrows

        public void RenderWithNullWriterThrows() {
            // Arrange
            RazorView view = new RazorView(new ControllerContext(), "~/viewPath", null, false, Enumerable.Empty<string>());
            Mock<ViewContext> viewContextMock = new Mock<ViewContext>();

            MockBuildManager buildManager = new MockBuildManager("~/viewPath", typeof(object));
            view.BuildManager = buildManager;

            // Act & Assert
            ExceptionHelper.ExpectArgumentNullException(
                () => view.Render(viewContextMock.Object, null),
                "writer"
            );
        }
開發者ID:adrianvallejo,項目名稱:MVC3_Source,代碼行數:14,代碼來源:RazorViewTest.cs

示例13: RenderWithUnsupportedTypeThrows

        public void RenderWithUnsupportedTypeThrows()
        {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(int));
            WebFormView view = new WebFormView(new ControllerContext(), "view path", null);
            view.BuildManager = buildManagerMock;

            // Act & Assert
            Assert.Throws<InvalidOperationException>(
                () => view.Render(context, null),
                "The view at 'view path' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>."
                );
        }
開發者ID:JokerMisfits,項目名稱:linux-packaging-mono,代碼行數:14,代碼來源:WebFormViewTest.cs

示例14: ViewCreationConsultsSetActivator

        public void ViewCreationConsultsSetActivator() {
            // Arrange
            object viewInstance = new object();
            Mock<IViewPageActivator> activator = new Mock<IViewPageActivator>(MockBehavior.Strict);
            ControllerContext controllerContext = new ControllerContext();
            activator.Setup(a => a.Create(controllerContext, typeof(object))).Returns(viewInstance).Verifiable();
            MockBuildManager buildManager = new MockBuildManager("view path", typeof(object));
            BuildManagerCompiledView view = new TestableBuildManagerCompiledView(controllerContext, "view path", activator.Object) { BuildManager = buildManager };

            // Act
            view.Render(new Mock<ViewContext>().Object, new Mock<TextWriter>().Object);

            // Assert
            activator.Verify();
        }
開發者ID:jesshaw,項目名稱:ASP.NET-Mvc-3,代碼行數:15,代碼來源:BuildManagerCompiledViewTest.cs

示例15: TestableBuildManagerViewEngine

        public void FileExistsQueriesBuildManagerForFilesThatPathProviderDoesNotFindWhenRunningInPrecompiledNonUpdateableApp()
        {
            // Arrange
            string testPath = "/Path.txt";
            var engine = new TestableBuildManagerViewEngine(pathProvider: CreatePathProvider("some random path"));
            engine.SetIsPrecompiledNonUpdateableSite(true);
            var buildManagerMock = new MockBuildManager(testPath, typeof(object));
            engine.BuildManager = buildManagerMock;

            // Act
            bool result = engine.FileExists(testPath);

            // Assert
            Assert.True(result);
        }
開發者ID:ahmetgoktas,項目名稱:aspnetwebstack,代碼行數:15,代碼來源:BuildManagerViewEngineTest.cs


注:本文中的System.Web.Mvc.Test.MockBuildManager類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。