public async void GetTagList_Returns_PostCount_With_Tags() { // Arrange: tag2 are all labeled on drafts SeedTestPosts(11); // Act var list = await _tagRepo.GetListAsync(); // Assert: therefore tag2 count is 0 Assert.Equal(2, list.Count); Assert.Equal(0, list[1].Count); }
public async void UpdatePost_Can_Add_None_Tracked_Tag() { // Arrange: given 1 post with 2 tags SeedTestPost(); // and a non-tracked tag var tagRepo = new SqlTagRepository(_db); await tagRepo.CreateAsync(new Tag { Title = "Java", Slug = "java" }); var tagNonTracked = (await tagRepo.GetListAsync()).Single(t => t.Title == "Java"); // Act: when user updates post by adding the non-tracked tag var post = _db.Set <Post>().Include(p => p.PostTags).Single(p => p.Slug == POST_SLUG); post.PostTags.Add(new PostTag { Post = post, Tag = tagNonTracked }); await _postRepo.UpdateAsync(post); // Assert: now post has 3 tags var postAgain = _db.Set <Post>().Include(p => p.PostTags).Single(p => p.Id == post.Id); Assert.Equal(3, postAgain.PostTags.Count()); }