Exemple #1
0
        public void ChangeFeedbackStatus_WithNegativeId_ShouldReturnNotFound()
        {
            //Act
            var controller = new FeedbackController(null);
            var result     = controller.ChangeFeedbackStatus(-1);

            //Assert
            Assert.IsInstanceOfType(result as NotFoundResult, typeof(NotFoundResult));
        }
Exemple #2
0
        public void ChangeFeedbackStatus_FeedbackIsNull_ShouldReturnNotFound()
        {
            var dbContext = new MockDbContext().GetContext();

            dbContext.Feedbacks.Add(new Feedback()
            {
                Id = 1
            });
            dbContext.SaveChanges();

            //Act
            var controller = new FeedbackController(dbContext);
            var result     = controller.ChangeFeedbackStatus(2);

            //Assert
            Assert.IsInstanceOfType(result as NotFoundResult, typeof(NotFoundResult));
        }
Exemple #3
0
        public void ChangeFeedbackStatus_ShouldReturn_RedirectToActionResult()
        {
            var dbContext = new MockDbContext().GetContext();

            dbContext.Feedbacks.Add(new Feedback()
            {
                Id = 1, IsRead = false
            });
            dbContext.SaveChanges();

            //Act
            var controller       = new FeedbackController(dbContext);
            var result           = controller.ChangeFeedbackStatus(1);
            var redirectToAction = result as RedirectToActionResult;

            //Assert
            Assert.IsInstanceOfType(redirectToAction, typeof(RedirectToActionResult));
        }
Exemple #4
0
        public void ChangeFeedbackStatus_FeedbackIsNotRead_ShouldReturnIsRead()
        {
            var dbContext = new MockDbContext().GetContext();

            dbContext.Feedbacks.Add(new Feedback()
            {
                Id = 1, IsRead = false
            });
            dbContext.SaveChanges();

            //Act
            var controller = new FeedbackController(dbContext);
            var result     = controller.ChangeFeedbackStatus(1);
            var feed       = dbContext.Feedbacks.Find(1);

            //Assert
            Assert.AreEqual(feed.IsRead, true);
        }
Exemple #5
0
        public void ChangeFeedbackStatus_ShouldRedirectTo_AdminFeedbackAll()
        {
            var dbContext = new MockDbContext().GetContext();

            dbContext.Feedbacks.Add(new Feedback()
            {
                Id = 1, IsRead = false
            });
            dbContext.SaveChanges();

            //Act
            var controller       = new FeedbackController(dbContext);
            var result           = controller.ChangeFeedbackStatus(1);
            var redirectToAction = result as RedirectToActionResult;

            //Assert
            Assert.AreEqual(redirectToAction.RouteValues["area"], "admin");
            Assert.AreEqual(redirectToAction.ControllerName, "feedback");
            Assert.AreEqual(redirectToAction.ActionName, "all");
        }