Ejemplo n.º 1
0
        public void op_HtmlRepresentation()
        {
            var response = new Mock<HttpResponseBase>(MockBehavior.Strict);
            response
                .SetupSet(x => x.StatusCode = (int)HttpStatusCode.NotFound)
                .Verifiable();

            var context = new Mock<HttpContextBase>(MockBehavior.Strict);
            context
                .Setup(x => x.Response)
                .Returns(response.Object)
                .Verifiable();

            var controller = new NotFoundController();
            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            Assert.IsType<ViewResult>(controller.HtmlRepresentation());
            Assert.Equal("The requested resource was not found.", controller.ViewBag.Message);

            response.VerifyAll();
        }
        public void op_HtmlRepresentation()
        {
            var response = new Mock <HttpResponseBase>(MockBehavior.Strict);

            response
            .SetupSet(x => x.StatusCode = (int)HttpStatusCode.NotFound)
            .Verifiable();

            var context = new Mock <HttpContextBase>(MockBehavior.Strict);

            context
            .Setup(x => x.Response)
            .Returns(response.Object)
            .Verifiable();

            var controller = new NotFoundController();

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            Assert.IsType <ViewResult>(controller.HtmlRepresentation());
            Assert.Equal("The requested resource was not found.", controller.ViewBag.Message);

            response.VerifyAll();
        }