public void DeleteConfirmedView_NotNull()
        {
            var mock = new Mock <IAuthorLogic>();

            mock.Setup(a => a.Delete(1));
            AuthorController controller = new AuthorController(mock.Object);
            ViewResult       result     = controller.DeleteConfirmed(1) as ViewResult;

            Assert.IsNotNull(result);
        }
        public void DeleteConfirmed_InvalidId_ReturnsHttpNotFound()
        {
            //Arrange
            IRepository mockRepo = Substitute.For <IRepository>();

            mockRepo.Authors.Returns(_authors);

            //Act
            int invalidId           = 999;
            AuthorController target = new AuthorController(mockRepo);
            ActionResult     result = target.DeleteConfirmed(invalidId);

            //Assert
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
        public void DeleteConfirmed_ValidId_ReturnsCorrectView()
        {
            //Arrange
            IRepository mockRepo = Substitute.For <IRepository>();

            mockRepo.Authors.Returns(_authors);

            //Act
            int validId             = 1;
            AuthorController target = new AuthorController(mockRepo);
            ActionResult     result = target.DeleteConfirmed(validId);

            //Assert
            mockRepo.Received(1).RemoveAuthor(Arg.Any <Author>());
            mockRepo.Received(1).SaveChanges();
            Assert.IsInstanceOf <RedirectToActionResult>(result);
            Assert.AreEqual("Index", (result as RedirectToActionResult).ActionName);
        }