コード例 #1
0
ファイル: PostTest.cs プロジェクト: ercanatbas/ZeroBlog
        public void PostCreate_ItShouldBeSuccessfully()
        {
            var post = Post.Create(DomainTestBase.CreateAUser(), "test", "test");

            post.ShouldNotBeNull();
            post.Content.ShouldNotBeNullOrEmpty();
            post.Title.ShouldNotBeNullOrEmpty();
            post.UserId.ShouldNotBeNull();
        }
コード例 #2
0
        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>());
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: PostTest.cs プロジェクト: ercanatbas/ZeroBlog
        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");
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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>());
        }
コード例 #7
0
        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>());
        }
コード例 #8
0
        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>());
        }
コード例 #9
0
        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>());
        }
コード例 #10
0
        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>());
        }
コード例 #11
0
        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>());
        }
コード例 #12
0
        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>());
        }
コード例 #13
0
        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>());
        }