public void EditPost_whenPostNotExist_notDone() { //Arange var postBo = new PostsBo(_postsRepo, _postRatigVotesRepo, _avatarImgRepo); const int postId = 1; const string title = "abc"; const string content = "def"; const bool enableCom = false; _postsRepo .GetItem(Arg.Is<int>(x => x >= 1)).ReturnsNull(); //Act postBo.EditPost(postId, title, content, enableCom); //Assert _postsRepo.Received(0).Save(); }
public void EditPost_EditPostOnceWithCorrectParamValue() { //Arange var postBo = new PostsBo(_postsRepo, _postRatigVotesRepo, _avatarImgRepo); const int postId = 1; const string title = "abc"; const string content = "def"; const bool enableCom = false; _postsRepo .GetItem(Arg.Is<int>(x => x >= 1)) .Returns(new Post { Id = postId, Title = "www", Content = "www", IsEnableComments = true }); //Act postBo.EditPost(postId, title, content, enableCom); //Assert var editedPost = _postsRepo.GetItem(postId); Assert.AreEqual(editedPost.Title, title); Assert.AreEqual(editedPost.Content, content); Assert.AreEqual(editedPost.IsEnableComments, enableCom); _postsRepo.Received(1).Save(); }