public void CopyConstructorSetsProperties()
        {
            // Arrange
            Mock <HttpContextBase> httpContext = new Mock <HttpContextBase>();

            httpContext.Setup(c => c.Items).Returns(new Hashtable());

            RequestContext requestContext = new RequestContext(httpContext.Object, new RouteData());
            Controller     controller     = new Mock <Controller>().Object;
            var            displayMode    = new DefaultDisplayMode("test");

            ControllerContext innerControllerContext = new ControllerContext(requestContext, controller);

            innerControllerContext.DisplayMode = displayMode;

            // Act
            ControllerContext outerControllerContext = new SubclassedControllerContext(innerControllerContext);

            // Assert
            Assert.Equal(requestContext, outerControllerContext.RequestContext);
            Assert.Equal(controller, outerControllerContext.Controller);

            // We don't actually set DisplayMode but verify it is identical to the inner controller context.
            Assert.Equal(displayMode, outerControllerContext.DisplayMode);
        }
Ejemplo n.º 2
0
        public void CopyConstructorSetsProperties() {
            // Arrange
            RequestContext requestContext = new RequestContext(new Mock<HttpContextBase>().Object, new RouteData());
            Controller controller = new Mock<Controller>().Object;

            ControllerContext innerControllerContext = new ControllerContext(requestContext, controller);

            // Act
            ControllerContext outerControllerContext = new SubclassedControllerContext(innerControllerContext);

            // Assert
            Assert.AreEqual(requestContext, outerControllerContext.RequestContext);
            Assert.AreEqual(controller, outerControllerContext.Controller);
        }
Ejemplo n.º 3
0
        public void CopyConstructorSetsProperties()
        {
            // Arrange
            RequestContext requestContext = new RequestContext(new Mock <HttpContextBase>().Object, new RouteData());
            Controller     controller     = new Mock <Controller>().Object;

            ControllerContext innerControllerContext = new ControllerContext(requestContext, controller);

            // Act
            ControllerContext outerControllerContext = new SubclassedControllerContext(innerControllerContext);

            // Assert
            Assert.AreEqual(requestContext, outerControllerContext.RequestContext);
            Assert.AreEqual(controller, outerControllerContext.Controller);
        }
        public void CopyConstructorSetsProperties()
        {
            // Arrange
            Mock<HttpContextBase> httpContext = new Mock<HttpContextBase>();
            httpContext.Setup(c => c.Items).Returns(new Hashtable());

            RequestContext requestContext = new RequestContext(httpContext.Object, new RouteData());
            Controller controller = new Mock<Controller>().Object;
            var displayMode = new DefaultDisplayMode("test");

            ControllerContext innerControllerContext = new ControllerContext(requestContext, controller);
            innerControllerContext.DisplayMode = displayMode;

            // Act
            ControllerContext outerControllerContext = new SubclassedControllerContext(innerControllerContext);

            // Assert
            Assert.Equal(requestContext, outerControllerContext.RequestContext);
            Assert.Equal(controller, outerControllerContext.Controller);

            // We don't actually set DisplayMode but verify it is identical to the inner controller context.
            Assert.Equal(displayMode, outerControllerContext.DisplayMode);
        }