Delete() private method

private Delete ( int id ) : System.Web.Mvc.ActionResult
id int
return System.Web.Mvc.ActionResult
Beispiel #1
0
        public void Delete_Method_Should_Return_Httpnotfoubdresult()
        {
            // Arrange
            FunctionalTestHelper.CreateAccountAndBlog(_dbContext);
            FunctionalTestHelper.CreateOnePost(_dbContext);

            // Act
            _controller = new PostController();
            var result = _controller.Delete(1000) as HttpNotFoundResult;

            // Assert
            result.ShouldNotBeNull();
            result.ShouldBeOfType(typeof(HttpNotFoundResult));
        }
Beispiel #2
0
        public void Delete_Method_Should_Delete_Post()
        {
            // Arrange
            FunctionalTestHelper.CreateAccountAndBlog(_dbContext);
            FunctionalTestHelper.CreateOnePost(_dbContext);

            _controller = new PostController();
            _controller.SetFakeControllerContext();

            // Act
            var result = _controller.Delete(1) as RedirectToRouteResult;

            // Assert
            result.RouteValues["controller"].ShouldEqual("Home");
            result.RouteValues["action"].ShouldEqual("Index");

            _dbContext.Posts.Count().ShouldEqual(0);
        }
Beispiel #3
0
        public void Delete_Method_Should_Delete_Post_Via_Ajax()
        {
            // Arrange
            FunctionalTestHelper.CreateAccountAndBlog(_dbContext);
            FunctionalTestHelper.CreateOnePost(_dbContext);

            _controller = new PostController();
            _controller.SetFakeControllerContext(isAjaxRequest:true);

            // Act
            var result = _controller.Delete(1) as JsonResult;

            // Assert
            var serializer = new JavaScriptSerializer();
            var output = serializer.Serialize(result.Data);
            Assert.AreEqual(@"{""success"":true}", output);

            _dbContext.Posts.Count().ShouldEqual(0);
        }