Skip to content

Commit

Permalink
Test case for check
Browse files Browse the repository at this point in the history
  • Loading branch information
cwetanow committed Apr 23, 2017
1 parent fe87e07 commit 7337b72
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Logs.Web.Tests/Controllers/CommentControllerTests/EditTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ namespace Logs.Web.Tests.Controllers.CommentControllerTests
[TestFixture]
public class EditTests
{
[TestCase(1, "content")]
public void TestEdit_ModelStateIsNotValid_ShouldNotCallCommentServiceEditCommentCorrectly(int commentId, string content)
{
// Arrange
var model = new CommentViewModel { CommentId = commentId, Content = content };

var mockedService = new Mock<ICommentService>();
mockedService.Setup(s => s.EditComment(It.IsAny<int>(), It.IsAny<string>()))
.Returns(new Comment());

var mockedAuthenticationProvider = new Mock<IAuthenticationProvider>();

var controller = new CommentController(mockedService.Object, mockedAuthenticationProvider.Object);
controller.ModelState.AddModelError("", "");

// Act
controller.Edit(model);

// Assert
mockedService.Verify(s => s.EditComment(It.IsAny<int>(), It.IsAny<string>()), Times.Never);
}

[TestCase(1, "content")]
public void TestEdit_ShouldCallCommentServiceEditCommentCorrectly(int commentId, string content)
{
Expand Down

0 comments on commit 7337b72

Please sign in to comment.