public void PostCreate_ItShouldBeSuccessfully() { var post = Post.Create(DomainTestBase.CreateAUser(), "test", "test"); post.ShouldNotBeNull(); post.Content.ShouldNotBeNullOrEmpty(); post.Title.ShouldNotBeNullOrEmpty(); post.UserId.ShouldNotBeNull(); }
public void DeleteAComment_GIVENIdParameter_WHENRemoving_THENItBecomesSuccessfully() { _commentRepository.GetComment(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAComment()); _commentService.DeleteAComment(1, 1); _commentRepository.Received(1).GetComment(Arg.Any <int>(), Arg.Any <int>()); _commentRepository.Received(1).Delete(Args.AnyEntity <Comment>()); }
public void CommentCreate_ItShouldBeSuccessfully() { var comment = Comment.Create(DomainTestBase.CreateAPost(), "test", "test", "test"); comment.ShouldNotBeNull(); comment.FirstName.ShouldNotBeNullOrEmpty(); comment.LastName.ShouldNotBeNullOrEmpty(); comment.Message.ShouldNotBeNullOrEmpty(); comment.PostId.ShouldNotBeNull(); }
public void PostUpdate_ItShouldBeSuccessfully() { var post = Post.Create(DomainTestBase.CreateAUser(), "test", "test"); post.Update("test1", "test2"); post.ShouldNotBeNull(); post.Content.ShouldBe("test2"); post.Title.ShouldBe("test1"); }
public void CommentUpdate_ItShouldBeSuccessfully() { var comment = Comment.Create(DomainTestBase.CreateAPost(), "test", "test", "test"); comment.Update("test1", "test2", "test3"); comment.ShouldNotBeNull(); comment.FirstName.ShouldBe("test1"); comment.LastName.ShouldBe("test2"); comment.Message.ShouldBe("test3"); }
public void DeleteAPost_GIVENIdParameter_WHENRemoving_THENItBecomesSuccessfully() { _postRepository.GetPost(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAPost()); _postService.DeleteAPost(1); _cacheService.Remove(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); _postRepository.Received(1).GetPost(Arg.Any <int>(), Arg.Any <int>()); _postRepository.Received(1).Delete(Args.AnyEntity <Post>()); _cacheService.Received(1).Remove(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); }
public void GetAllComment_WHENGetting_THENItBecomesSuccessfully() { _commentRepository.Query(Args.AnyEntity <Comment>()).Returns(DomainTestBase.CreateAComment().ToList()); _mapperService.Map <IEnumerable <CommentResult> >(Arg.Any <List <Comment> >()) .Returns(new CommentResult { Id = 1, PostId = 1, FirstName = "test", LastName = "test", Message = "test" }.ToList()); var result = _commentService.GetAllComments(1); result.ShouldNotBeNull(); _commentRepository.Received(1).Query(Args.AnyEntity <Comment>()); }
public void GetAPost_WHENGetting_THENItBecomesSuccessfully() { _coreService.User.Id.Returns(1); _postRepository.GetPost(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAPost()); _mapperService.Map <PostResult>(Arg.Any <Post>()) .Returns(new PostResult { Id = 1, Title = "test" }); var result = _postService.GetAPost(1); result.ShouldNotBeNull(); _postRepository.Received(1).GetPost(Arg.Any <int>(), Arg.Any <int>()); }
public void UpdateAComment_GIVENUpdateRequest_WHENUpdating_THENItBecomesSuccessfully() { _commentRepository.GetComment(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAComment()); _commentService.UpdateAComment(new UpdateCommentRequest { Id = 1, PostId = 1, FirstName = "test", LastName = "test", Message = "test", }); _commentRepository.Received().GetComment(Arg.Any <int>(), Arg.Any <int>()); _commentRepository.Received(1).Update(Arg.Any <Comment>()); }
public void CreateAComment_GIVENCommentPostRequest_WHENInserting_THENItBecomesSuccessfully() { _postRepository.GetCommentForPost(Arg.Any <int>()).Returns(DomainTestBase.CreateAPost()); _commentRepository.Insert(Arg.Any <Comment>()).Returns(DomainTestBase.CreateAComment()); var result = _commentService.CreateAComment(new CommentRequest { FirstName = "test", LastName = "test", Message = "test", PostId = 1 }); result.ShouldNotBeNull(); _postRepository.Received(1).GetCommentForPost(Arg.Any <int>()); }
public void GetAllPost_WHENGettingDatabase_THENItBecomesSuccessfully() { _coreService.User.Id.Returns(1); _cacheService.GetList <PostResult>(Arg.Any <string>()).Returns((IEnumerable <PostResult>)null); _postRepository.Query(Args.AnyEntity <Post>()).Returns(DomainTestBase.CreateAPost().ToList()); _mapperService.Map <IEnumerable <PostResult> >(Arg.Any <List <Post> >()) .Returns(new PostResult { Id = 1, Title = "test" }.ToList()); var result = _postService.GetAllPost(); result.ShouldNotBeNull(); _postRepository.Received(1).Query(Args.AnyEntity <Post>()); _cacheService.Received(1).GetList <PostResult>(Arg.Any <string>()); }
public void UpdateAPost_GIVENUpdateRequest_WHENUpdating_THENItBecomesSuccessfully() { _coreService.User.Id.Returns(1); _postRepository.GetPost(Arg.Any <int>(), Arg.Any <int>()).Returns(DomainTestBase.CreateAPost()); _cacheService.Update(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); _postService.UpdateAPost(new UpdateRequest { Id = 1, Title = "test title", Content = "test content" }); _postRepository.Received(1).GetPost(Arg.Any <int>(), Arg.Any <int>()); _postRepository.Received(1).Update(Arg.Any <Post>()); _cacheService.Received(1).Update(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); }
public void CreateAPost_GIVENPostRequest_WHENInserting_THENItBecomesSuccessfully() { _coreService.User.Id.Returns(1); _userRepository.GetUser(Arg.Any <int>()).Returns(DomainTestBase.CreateAUser()); _postRepository.Insert(Arg.Any <Post>()).Returns(DomainTestBase.CreateAPost()); _cacheService.Insert(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); var result = _postService.CreateAPost(new PostRequest { Title = "test title", Content = "test content" }); result.ShouldNotBeNull(); _userRepository.Received(1).GetUser(Arg.Any <int>()); _postRepository.Received(1).Insert(Arg.Any <Post>()); _cacheService.Received(1).Insert(Arg.Any <string>(), Arg.Any <Post>(), Arg.Any <int>()); }