Example #1
0
        public void Delete_ReturnsCorrectActionType_RedirectToActionResult()
        {
            BlogsController controller = new BlogsController();
            IActionResult   view       = controller.Delete(1, 1);

            Assert.IsInstanceOfType(view, typeof(RedirectToActionResult));
        }
Example #2
0
        public void DeleteBlogNegative()
        {
            var             repo       = new Mock <BlogRepository>(db);
            BlogsController controller = new BlogsController(repo.Object);
            var             data       = controller.Delete(9);

            Assert.AreEqual("Blog could not be deleted", data);
        }
Example #3
0
        public void Delete_RedirectsToCorrectAction_Show()
        {
            BlogsController        controller   = new BlogsController();
            RedirectToActionResult actionResult = controller.Delete(1, 1) as RedirectToActionResult;
            string result = actionResult.ActionName;

            Assert.AreEqual(result, "Show");
        }
Example #4
0
        public void DeleteBlogRemovesFromList()
        {
            var  userID     = "dd";
            Blog sampleBlog = new Blog(userID, "blog1", "description");

            controller.Create(sampleBlog);

            var blogs = controller.GetUserBlogs(userID).Value;

            sampleBlog = blogs.FirstOrDefault(target => target.Name == sampleBlog.Name);

            Assert.NotNull(sampleBlog);

            controller.Delete(sampleBlog.ID);

            sampleBlog = controller.GetUserBlogs(userID).Value
                         .FirstOrDefault(target => target.Name == sampleBlog.Name);
            Assert.Null(sampleBlog);
        }
        public void BlogControllerDelete()
        {
            var result = _ctrl.Delete("96d5b379-7e1d-4dac-a6ba-1e50db561b04");

            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }
        public async void Delete_IdIsNull_ReturnNotFound()
        {
            var result = await _controller.Delete(null);

            Assert.IsType <NotFoundResult>(result);
        }