public void CanEdit_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.CanEdit(userId, comment); //Assert Assert.IsFalse(result); }
public void CanEdit_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.CanEdit(-1, comment)); Assert.Throws<ArgumentOutOfRangeException>(() => target.CanEdit(0, comment)); }
public void CanEdit_PermittedPeriodForEditingExpired_ReturnsFalse() { // Arrange Comment comment = new Comment { UserId = 1, Date = DateTime.Now.AddSeconds(-(this._serviceSettings.PermittedPeriodForEditing + 1)) }; // Arrange - create target ICommentService target = new CommentService(new Mock<IUnitOfWork>().Object, this._commentValidationMock.Object, this._serviceSettings); // Act bool result = target.CanEdit(comment.UserId, comment); //Assert Assert.IsFalse(result); }
public void CanEdit_UserCanEditTheComment_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.CanEdit(comment.UserId, comment); //Assert Assert.IsTrue(result); }
public void CanEdit_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.CanEdit(userId, null)); }