public void Delete_By_Topic_With_One_Topics_Per_Tag() { var tagRepository = Substitute.For <ITopicTagRepository>(); var topicRepository = Substitute.For <ITopicRepository>(); var topicTagService = new TopicTagService(tagRepository, topicRepository); var topicTag = new TopicTag { Tag = "tag-one", Topics = new List <Topic> { new Topic { Name = "HulkRules" } } }; var topic = new Topic { Tags = new List <TopicTag> { topicTag } }; topicTagService.DeleteByTopic(topic); Assert.IsTrue(topicTag.Topics.Count() <= 1); tagRepository.Received().Delete(Arg.Is(topicTag)); }
public void Delete_By_Topic_With_Multiple_Topics_Per_Tag() { var tagRepository = Substitute.For <ITopicTagRepository>(); var topicRepository = Substitute.For <ITopicRepository>(); var topicTagService = new TopicTagService(tagRepository, topicRepository); var topicTag = new TopicTag { Tag = "tag-one", Topics = new List <Topic> { new Topic { Name = "Tony" }, new Topic { Name = "Stark" } } }; var topic = new Topic { Tags = new List <TopicTag> { topicTag } }; topicTagService.DeleteByTopic(topic); Assert.IsFalse(topicTag.Topics.Count() <= 1); tagRepository.DidNotReceive().Delete(Arg.Is(topicTag)); }