Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
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>());
        }
Ejemplo n.º 4
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>());
        }
Ejemplo n.º 5
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>());
        }
Ejemplo n.º 6
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>());
        }
Ejemplo n.º 7
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>());
        }
Ejemplo n.º 8
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>());
        }