public void BadRequest_returns_BadRequest_View_with_400()
        {
            var status = (int)HttpStatusCode.BadRequest;

            controller.HttpContext.Response.StatusCode = status;

            var result = controller.BadRequest();

            Assert.IsInstanceOf(typeof(ViewResult), result);

            var viewResult = result as ViewResult;

            Assert.AreEqual("BadRequest", viewResult.ViewName);

            Assert.AreEqual(status, response.Object.StatusCode);

            Assert.IsInstanceOf(typeof(HandleErrorInfo), viewResult.Model);
            Assert.AreEqual("Bad Request", (viewResult.Model as HandleErrorInfo)?.Exception?.Message);
        }
Exemplo n.º 2
0
        public void ReturnViewBadRequest()
        {
            // Arrange
            var errorController = new ErrorController();

            var badRequest = errorController.BadRequest() as ViewResult;

            // Act & Assert
            Assert.AreEqual("BadRequest", badRequest.ViewName);
        }
Exemplo n.º 3
0
        public void BadRequestTest()
        {
            //Arrange

            //Act
            ViewResult result = controller.BadRequest() as ViewResult;

            //Assert

            Assert.IsNotNull(result);
        }
        public void BadRequest()
        {
            // Arrange
            var controller = new ErrorController();

            // Act
            var result = controller.BadRequest() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }