コード例 #1
0
        public void DeleteUser_Should_Return_HttpNotFoundResult_When_Actual_Parameter_Is_Null()
        {
            //Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            //Act
            ActionResult vr = (ActionResult)controller.DeleteUser(null);

            //Assert
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), vr);
        }
コード例 #2
0
        public void DeleteVoteGetWithNonexistentIDReturnsHTTPNotFound()
        {
            // Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            // Act
            var vr = controller.DeleteVote(123456);

            // Assert
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), vr);
        }
コード例 #3
0
        public void ListCommentsToDeleteOrEdit_Should_Not_Return_Null()
        {
            //Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            //Act
            ViewResult vr = (ViewResult)controller.ListCommentsToDeleteOrEdit("or20156");

            //Assert
            Assert.IsNotNull(vr);
        }
コード例 #4
0
        public void DeleteNullVoteGetReturnsHTTPNotFound()
        {
            // Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            // Act
            var vr = controller.DeleteVote(null);

            // Assert
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), vr);
        }
コード例 #5
0
        public void DeleteVoteWithNonexistentIDRetunsHTTPNotFound()
        {
            // Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            // Act
            ActionResult vr = (ActionResult)controller.DeleteVote(123456, new UserVote());

            // Assert
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), vr);
        }
コード例 #6
0
        public void DeleteNullVoteReturnsHTTPNotFound()
        {
            // Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            // Act
            ActionResult vr = (ActionResult)controller.DeleteVote(null, new UserVote());

            // Assert
            Assert.IsInstanceOf(typeof(HttpNotFoundResult), vr);
        }
コード例 #7
0
        public void SearchToDelOrEditShouldNotReturnNull()
        {
            //Arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            //act
            ViewResult vr = (ViewResult)controller.SearchToDeleteOrEdit();

            //assert
            Assert.IsNotNull(vr);
        }
コード例 #8
0
        public void ListUsersToDeleteOrEdit_Test()
        {
            //arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            //act
            ViewResult        vr = (ViewResult)controller.ListUsersToDeleteOrEdit("2452345245", "xyz");
            List <AspNetUser> us = (List <AspNetUser>)vr.ViewData.Model;

            //assert
            Assert.IsNotNull(vr);
            Assert.IsTrue(us.Exists(u => u.Id.Equals("abc")));
        }
コード例 #9
0
        public void DeleteVoteWithNullShouldReturnHttpNotFoundTest()
        {
            int dvoteCount = 0;
            int totalVotes = 4;

            moq.Setup(m => m.DeleteUserVote(It.IsAny <UserVote>())).Callback(() => { dvoteCount = ++dvoteCount; totalVotes = --totalVotes; });
            //arrange
            SysAdminController controller = new SysAdminController(moq.Object);
            //act
            RedirectToRouteResult r = (RedirectToRouteResult)controller.DeleteVote(0, null);

            //assert

            Assert.AreEqual(dvoteCount, 1);
            Assert.AreEqual(totalVotes, 3);
            Assert.AreEqual(r.RouteValues["Action"], "SearchToDeleteOrEdit");

            //moq.Setup(m => m.FindVoteById(It.IsAny < int?>())).Returns(new UserVote { id = 0, ucblid = "or20156", ucnetuid = "xyz", votebit = 1 });
        }