示例#1
0
        public void CanDelete_UserIsNotAuthorOfTheComment_ReturnsFalse()
        {
            // Arrange
            int userId = 1;
            Comment comment = new Comment { UserId = userId + 1 };

            ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object,
            this._serviceSettings);

            // Act
            bool result = target.CanDelete(userId, comment);

            //Assert
            Assert.IsFalse(result);
        }
示例#2
0
        public void CanDelete_UserIdIsLessOrEqualToZero_ThrowsArgumentOutOfRangeException()
        {
            // Arrange
            Comment comment = new Comment { CommentId = 1 };

            ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object,
            this._serviceSettings);

            // Act and Assert
            Assert.Throws<ArgumentOutOfRangeException>(() => target.CanDelete(-1, comment));
            Assert.Throws<ArgumentOutOfRangeException>(() => target.CanDelete(0, comment));
        }
示例#3
0
        public void CanDelete_PermittedPeriodForDeletingExpired_ReturnsFalse()
        {
            // Arrange
            Comment comment = new Comment
            { UserId = 1, Date = DateTime.Now.AddSeconds(-(this._serviceSettings.PermittedPeriodForDeleting + 1)) };

            // Arrange - create target
            ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object,
            this._serviceSettings);

            // Act
            bool result = target.CanDelete(comment.UserId, comment);

            //Assert
            Assert.IsFalse(result);
        }
示例#4
0
        public void CanDelete_UserCanDeleteTheComment_ReturnsTrue()
        {
            // Arrange
            Comment comment = new Comment { UserId = 1, Date = DateTime.Now };

            // Arrange - create target
            ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object,
            this._serviceSettings);

            // Act
            bool result = target.CanDelete(comment.UserId, comment);

            //Assert
            Assert.IsTrue(result);
        }
示例#5
0
        public void CanDelete_CommentIsNull_ThrowsArgumentNullException()
        {
            // Arrange
            int userId = 1;

            ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object,
            this._serviceSettings);

            // Act and Assert
            Assert.Throws<ArgumentNullException>(() => target.CanDelete(userId, null));
        }