Пример #1
0
        public void RenderWithViewUserControlRendersView()
        {
            // Arrange
            ViewContext               context           = new Mock <ViewContext>().Object;
            MockBuildManager          buildManager      = new MockBuildManager("view path", typeof(object));
            Mock <IViewPageActivator> activator         = new Mock <IViewPageActivator>(MockBehavior.Strict);
            ControllerContext         controllerContext = new ControllerContext();
            StubViewUserControl       viewUserControl   = new StubViewUserControl();

            activator
            .Setup(l => l.Create(controllerContext, typeof(object)))
            .Returns(viewUserControl);
            WebFormView view = new WebFormView(
                controllerContext,
                "view path",
                null,
                activator.Object
                )
            {
                BuildManager = buildManager
            };

            // Act
            view.Render(context, null);

            // Assert
            Assert.Equal(context, viewUserControl.ResultViewContext);
        }
Пример #2
0
        public void RenderWithViewUserControlRendersView()
        {
            // Arrange
            ViewContext         context          = new Mock <ViewContext>().Object;
            StubViewUserControl viewUserControl  = new StubViewUserControl();
            MockBuildManager    buildManagerMock = new MockBuildManager("view path", typeof(object), viewUserControl);
            WebFormView         view             = new WebFormView("view path", null);

            view.BuildManager = buildManagerMock;

            // Act
            view.Render(context, null);

            // Assert
            Assert.AreEqual(context, viewUserControl.ResultViewContext);
        }
Пример #3
0
        public void RenderWithViewUserControlAndMasterThrows()
        {
            // Arrange
            ViewContext         context          = new Mock <ViewContext>().Object;
            StubViewUserControl viewUserControl  = new StubViewUserControl();
            MockBuildManager    buildManagerMock = new MockBuildManager("view path", typeof(object), viewUserControl);
            WebFormView         view             = new WebFormView("view path", "master path");

            view.BuildManager = buildManagerMock;

            // Act & Assert
            ExceptionHelper.ExpectException <InvalidOperationException>(
                () => view.Render(context, null),
                "A master name cannot be specified when the view is a ViewUserControl."
                );
        }
        public void RenderWithViewUserControlRendersView()
        {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            MockBuildManager buildManager = new MockBuildManager("view path", typeof(object));
            Mock<IViewPageActivator> activator = new Mock<IViewPageActivator>(MockBehavior.Strict);
            ControllerContext controllerContext = new ControllerContext();
            StubViewUserControl viewUserControl = new StubViewUserControl();
            activator.Setup(l => l.Create(controllerContext, typeof(object))).Returns(viewUserControl);
            WebFormView view = new WebFormView(controllerContext, "view path", null, activator.Object) { BuildManager = buildManager };

            // Act
            view.Render(context, null);

            // Assert
            Assert.Equal(context, viewUserControl.ResultViewContext);
        }
Пример #5
0
        public void RenderWithViewUserControlRendersView() {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            StubViewUserControl viewUserControl = new StubViewUserControl();
            MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(object), viewUserControl);
            WebFormView view = new WebFormView("view path", null);
            view.BuildManager = buildManagerMock;

            // Act
            view.Render(context, null);

            // Assert
            Assert.AreEqual(context, viewUserControl.ResultViewContext);
        }
Пример #6
0
        public void RenderWithViewUserControlAndMasterThrows() {
            // Arrange
            ViewContext context = new Mock<ViewContext>().Object;
            StubViewUserControl viewUserControl = new StubViewUserControl();
            MockBuildManager buildManagerMock = new MockBuildManager("view path", typeof(object), viewUserControl);
            WebFormView view = new WebFormView("view path", "master path");
            view.BuildManager = buildManagerMock;

            // Act & Assert
            ExceptionHelper.ExpectException<InvalidOperationException>(
                () => view.Render(context, null),
                "A master name cannot be specified when the view is a ViewUserControl."
            );
        }