Esempio n. 1
0
        public void AddPost_AddPostOnceWithCorrectParamValue()
        {
            //Arange
            var postBo = new PostsBo(_postsRepo, _postRatigVotesRepo, _avatarImgRepo);
            const int userId = 2;
            const string title = "abc";
            const string content = "def";
            const bool enableCom = false;
            _postsRepo
               .Query()
               .Returns(new List<Post>
               {
                    new Post
                    {
                        Id = 1,
                        Title = "cba"
                    }
               }.AsQueryable());

            //Act

            postBo.AddNewPost(userId, title, content, enableCom);

            //Assert
            _postsRepo
                .Received(1).Create(Arg.Is<Post>(x =>
                        x.UserId == userId &&
                        x.Title == title &&
                        x.Content == content &&
                        x.IsEnableComments == enableCom));
        }
Esempio n. 2
0
        public void AddPost_PostTitleAlreadyExist_notCreate()
        {
            //Arange
            var postBo = new PostsBo(_postsRepo, _postRatigVotesRepo, _avatarImgRepo);
            const int userId = 1;
            const string title = "abc";
            const string content = "def";
            const bool enableCom = false;
            _postsRepo
                .Query()
                .Returns(new List<Post>
                {
                    new Post
                    {
                        Id = userId,
                        Title = title
                    }
                }.AsQueryable());

            //Act
            postBo.AddNewPost(userId, title, content, enableCom);

            //Assert
            _postsRepo
                .Received(0).Create(Arg.Is<Post>(new Post()));
        }