Exemplo n.º 1
0
        public void Should_return_404_view_for_invalid_page()
        {
            //Can't think of a way to test for bad route
              var controller = new ErrorController();
              var result = controller.Index();
              //var viewname = result.ViewName;
              //Assert.That(viewname, Is.EqualTo("NotFound"));

              Assert.That(true, Is.True);
        }
        public void ActionNotFoundShoudReturnPageNotFoundView()
        {
            var mockHttpContext = new Mock<HttpContextBase>();
            var response = new Mock<HttpResponseBase>();
            mockHttpContext.SetupGet(x => x.Response).Returns(response.Object);

            var controller = new ErrorController()
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = mockHttpContext.Object
                }
            };

            controller.WithCallTo(x => x.NotFound())
                .ShouldRenderView("NotFound");
        }