コード例 #1
0
ファイル: Story.cs プロジェクト: ptrstpp950/dotnetomaniak
        public void SubscribeComment(IUser byUser)
        {
            Check.Argument.IsNotNull(byUser, "byUser");
            var subscribtion = this.AddCommentSubscribtion(byUser);

            CommentSubscribtions.Add((CommentSubscribtion)subscribtion);
        }
コード例 #2
0
ファイル: Story.cs プロジェクト: ptrstpp950/dotnetomaniak
        public void UnsubscribeComment(IUser byUser)
        {
            Check.Argument.IsNotNull(byUser, "byUser");
            var subscribtion = this.RemoveCommentSubscribtion(byUser);

            if (subscribtion != null)
            {
                CommentSubscribtions.Remove((CommentSubscribtion)subscribtion);
            }
        }
コード例 #3
0
        public void FindById_Should_Return_Correct_Subscribtion()
        {
            CommentSubscribtions.Add(new CommentSubscribtion {
                UserId = Guid.NewGuid(), StoryId = Guid.NewGuid()
            });

            var userId  = CommentSubscribtions[0].UserId;
            var storyId = CommentSubscribtions[0].StoryId;

            Assert.NotNull(_commentSubscribtionRepository.FindById(storyId, userId));
        }
コード例 #4
0
ファイル: Story.cs プロジェクト: szymczakk/dotnetomaniak
        public virtual void UnsubscribeComment(IUser byUser)
        {
            Check.Argument.IsNotNull(byUser, "byUser");

            ICommentSubscribtionRepository repository   = IoC.Resolve <ICommentSubscribtionRepository>();
            CommentSubscribtion            subscribtion = repository.FindById(Id, byUser.Id) as CommentSubscribtion;

            if (subscribtion != null)
            {
                CommentSubscribtions.Remove(subscribtion);
                repository.Remove(subscribtion);
            }
        }
コード例 #5
0
        public void CountByStory_Should_Return_Correct_Count()
        {
            var storyId = Guid.NewGuid();

            CommentSubscribtions.Add(new CommentSubscribtion {
                StoryId = storyId
            });
            CommentSubscribtions.Add(new CommentSubscribtion {
                StoryId = storyId
            });
            CommentSubscribtions.Add(new CommentSubscribtion {
                StoryId = storyId
            });

            Assert.Equal(3, _commentSubscribtionRepository.CountByStory(storyId));
        }
コード例 #6
0
ファイル: Story.cs プロジェクト: szymczakk/dotnetomaniak
        public virtual void SubscribeComment(IUser byUser)
        {
            Check.Argument.IsNotNull(byUser, "byUser");

            ICommentSubscribtionRepository repository   = IoC.Resolve <ICommentSubscribtionRepository>();
            CommentSubscribtion            subscribtion = repository.FindById(Id, byUser.Id) as CommentSubscribtion;

            if (subscribtion == null)
            {
                subscribtion = new CommentSubscribtion
                {
                    Story = this,
                    User  = (User)byUser
                };

                CommentSubscribtions.Add(subscribtion);
                repository.Add(subscribtion);
            }
        }