diff options
author | crupest <crupest@outlook.com> | 2020-06-18 19:41:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-18 19:41:51 +0800 |
commit | 4214c5dd5724bbe0bb8225534568dd4b0e904068 (patch) | |
tree | 61846ff2588c4369811fd805dfd78b4eb3ba8d9e /Timeline.Tests/Services/TimelineServiceTest.cs | |
parent | 5f57f6d3f9c7bd94929f3e50915d57da7c031538 (diff) | |
download | timeline-4214c5dd5724bbe0bb8225534568dd4b0e904068.tar.gz timeline-4214c5dd5724bbe0bb8225534568dd4b0e904068.tar.bz2 timeline-4214c5dd5724bbe0bb8225534568dd4b0e904068.zip |
feat(back): Timeline service add post modified since.
Diffstat (limited to 'Timeline.Tests/Services/TimelineServiceTest.cs')
-rw-r--r-- | Timeline.Tests/Services/TimelineServiceTest.cs | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/Timeline.Tests/Services/TimelineServiceTest.cs b/Timeline.Tests/Services/TimelineServiceTest.cs index cb2ade61..4f081b5d 100644 --- a/Timeline.Tests/Services/TimelineServiceTest.cs +++ b/Timeline.Tests/Services/TimelineServiceTest.cs @@ -63,11 +63,11 @@ namespace Timeline.Tests.Services [InlineData("tl")]
public async Task Timeline_LastModified(string timelineName)
{
- _clock.ForwardCurrentTime();
+ var initTime = _clock.ForwardCurrentTime();
void Check(Models.Timeline timeline)
{
- timeline.NameLastModified.Should().Be(_clock.GetCurrentTime());
+ timeline.NameLastModified.Should().Be(initTime);
timeline.LastModified.Should().Be(_clock.GetCurrentTime());
}
@@ -90,5 +90,35 @@ namespace Timeline.Tests.Services await _timelineService.ChangeMember(timelineName, new List<string> { "admin" }, null);
await GetAndCheck();
}
+
+ [Theory]
+ [InlineData("@user")]
+ [InlineData("tl")]
+ public async Task GetPosts_ModifiedSince(string timelineName)
+ {
+ _clock.ForwardCurrentTime();
+
+ 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" };
+
+ DateTime testPoint = new DateTime();
+
+ foreach (var (content, index) in postContentList.Select((v, i) => (v, i)))
+ {
+ var t = _clock.ForwardCurrentTime();
+ if (index == 1)
+ testPoint = t;
+ await _timelineService.CreateTextPost(timelineName, userId, content, null);
+ }
+
+ var posts = await _timelineService.GetPosts(timelineName, testPoint);
+ posts.Should().HaveCount(2)
+ .And.Subject.Select(p => (p.Content as TextTimelinePostContent).Text).Should().Equal(postContentList.Skip(2));
+ }
}
}
|