public void SubscribeComment(IUser byUser) { Check.Argument.IsNotNull(byUser, "byUser"); var subscribtion = this.AddCommentSubscribtion(byUser); CommentSubscribtions.Add((CommentSubscribtion)subscribtion); }
public void UnsubscribeComment(IUser byUser) { Check.Argument.IsNotNull(byUser, "byUser"); var subscribtion = this.RemoveCommentSubscribtion(byUser); if (subscribtion != null) { CommentSubscribtions.Remove((CommentSubscribtion)subscribtion); } }
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)); }
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); } }
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)); }
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); } }