Beispiel #1
0
        public void PostCreate_ItShouldBeSuccessfully()
        {
            var post = Post.Create(DomainTestBase.CreateAUser(), "test", "test");

            post.ShouldNotBeNull();
            post.Content.ShouldNotBeNullOrEmpty();
            post.Title.ShouldNotBeNullOrEmpty();
            post.UserId.ShouldNotBeNull();
        }
Beispiel #2
0
        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");
        }
Beispiel #3
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>());
        }