diff options
author | crupest <crupest@outlook.com> | 2020-07-10 22:50:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-10 22:50:01 +0800 |
commit | 15e7467e6089537f0f3e2290f14a99b8a1fc2d76 (patch) | |
tree | a0ba363d1df5d1846f3a46bae4d0ffe7b72e1c89 /Timeline.Tests/Services/TimelineServiceTest.cs | |
parent | 838f9377514b03404afa1d6b6e42e981174178b5 (diff) | |
parent | 3735e7fecd2c9eaf525cedb55912f918aad20779 (diff) | |
download | timeline-15e7467e6089537f0f3e2290f14a99b8a1fc2d76.tar.gz timeline-15e7467e6089537f0f3e2290f14a99b8a1fc2d76.tar.bz2 timeline-15e7467e6089537f0f3e2290f14a99b8a1fc2d76.zip |
Merge pull request #115 from crupest/post-deleted
Add timeline post deleted field.
Diffstat (limited to 'Timeline.Tests/Services/TimelineServiceTest.cs')
-rw-r--r-- | Timeline.Tests/Services/TimelineServiceTest.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Timeline.Tests/Services/TimelineServiceTest.cs b/Timeline.Tests/Services/TimelineServiceTest.cs index 7e7242a2..123c2b7f 100644 --- a/Timeline.Tests/Services/TimelineServiceTest.cs +++ b/Timeline.Tests/Services/TimelineServiceTest.cs @@ -118,5 +118,44 @@ namespace Timeline.Tests.Services posts.Should().HaveCount(3)
.And.Subject.Select(p => (p.Content as TextTimelinePostContent).Text).Should().Equal(postContentList.Skip(1));
}
+
+ [Theory]
+ [InlineData("@user")]
+ [InlineData("tl")]
+ public async Task GetPosts_IncludeDeleted(string timelineName)
+ {
+ var userId = await _userService.GetUserIdByUsername("user");
+
+ var _ = TimelineHelper.ExtractTimelineName(timelineName, out var isPersonal);
+ if (!isPersonal)
+ await _timelineService.CreateTimeline(timelineName, userId);
+
+ var postContentList = new string[] { "a", "b", "c", "d" };
+
+ foreach (var content in postContentList)
+ {
+ await _timelineService.CreateTextPost(timelineName, userId, content, null);
+ }
+
+ var posts = await _timelineService.GetPosts(timelineName);
+ posts.Should().HaveCount(4);
+ posts.Select(p => p.Deleted).Should().Equal(Enumerable.Repeat(false, posts.Count));
+ posts.Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(postContentList);
+
+ foreach (var id in new long[] { posts[0].Id, posts[2].Id })
+ {
+ await _timelineService.DeletePost(timelineName, id);
+ }
+
+ posts = await _timelineService.GetPosts(timelineName);
+ posts.Should().HaveCount(2);
+ posts.Select(p => p.Deleted).Should().Equal(Enumerable.Repeat(false, posts.Count));
+ posts.Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(new string[] { "b", "d" });
+
+ posts = await _timelineService.GetPosts(timelineName, includeDeleted: true);
+ posts.Should().HaveCount(4);
+ posts.Select(p => p.Deleted).Should().Equal(new bool[] { true, false, true, false });
+ posts.Where(p => !p.Deleted).Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(new string[] { "b", "d" });
+ }
}
}
|