public void AddPost_InvalidTopicAlias_ThrowsTopicNotFoundException(string topicAlias, string content) { var testDatabaseContext = DbContextFactory.Create(); var post = new NewPostDTO { Content = content, AuthorID = 1 }; var service = new TopicService(testDatabaseContext); var exception = Record.Exception(() => service.AddPost(topicAlias, post)); Assert.IsType <TopicNotFoundException>(exception); }
public void AddPost_ValidTopicAlias_PostAdded(string topicAlias, string content) { var testDatabaseContext = DbContextFactory.Create(); var post = new NewPostDTO { Content = content, AuthorID = 1 }; var service = new TopicService(testDatabaseContext); service.AddPost(topicAlias, post); var topicData = service.GetTopicWithPosts(topicAlias); Assert.Contains(topicData.Posts, p => p.AuthorID == post.AuthorID && p.Content == post.Content); }