diff options
author | crupest <crupest@outlook.com> | 2020-07-10 20:29:02 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-07-10 20:29:02 +0800 |
commit | 3735e7fecd2c9eaf525cedb55912f918aad20779 (patch) | |
tree | a0ba363d1df5d1846f3a46bae4d0ffe7b72e1c89 | |
parent | a362066a9a8e64b8c8d58ec5952cb28caa217b35 (diff) | |
download | timeline-3735e7fecd2c9eaf525cedb55912f918aad20779.tar.gz timeline-3735e7fecd2c9eaf525cedb55912f918aad20779.tar.bz2 timeline-3735e7fecd2c9eaf525cedb55912f918aad20779.zip |
Add another integrated test.
-rw-r--r-- | Timeline.Tests/IntegratedTests/TimelineTest.cs | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/Timeline.Tests/IntegratedTests/TimelineTest.cs b/Timeline.Tests/IntegratedTests/TimelineTest.cs index 4ba8800e..ba335bd6 100644 --- a/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -1231,28 +1231,31 @@ namespace Timeline.Tests.IntegratedTests {
using var client = await CreateClientAsUser();
- DateTime testPoint = new DateTime();
var postContentList = new List<string> { "a", "b", "c", "d" };
+ var posts = new List<TimelinePostInfo>();
- foreach (var (content, index) in postContentList.Select((v, i) => (v, i)))
+ foreach (var content in postContentList)
{
var res = await client.PostAsJsonAsync(generator(1, "posts"),
new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
var post = res.Should().HaveStatusCode(200)
.And.HaveJsonBody<TimelinePostInfo>().Which;
- if (index == 1)
- testPoint = post.LastUpdated;
+ posts.Add(post);
await Task.Delay(1000);
}
{
+ var res = await client.DeleteAsync(generator(1, $"posts/{posts[2].Id}"));
+ res.Should().BeDelete(true);
+ }
+ {
var res = await client.GetAsync(generator(1, "posts",
- new Dictionary<string, string> { { "modifiedSince", testPoint.ToString("s", CultureInfo.InvariantCulture) } }));
+ new Dictionary<string, string> { { "modifiedSince", posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture) } }));
res.Should().HaveStatusCode(200)
.And.HaveJsonBody<List<TimelinePostInfo>>()
- .Which.Should().HaveCount(3)
- .And.Subject.Select(p => p.Content.Text).Should().Equal(postContentList.Skip(1));
+ .Which.Should().HaveCount(2)
+ .And.Subject.Select(p => p.Content.Text).Should().Equal("b", "d");
}
}
@@ -1289,5 +1292,45 @@ namespace Timeline.Tests.IntegratedTests posts.Select(p => p.Content == null).Should().Equal(true, false, true, false);
}
}
+
+ [Theory]
+ [MemberData(nameof(TimelineUrlGeneratorData))]
+ public async Task Post_ModifiedSince_And_IncludeDeleted(TimelineUrlGenerator urlGenerator)
+ {
+ using var client = await CreateClientAsUser();
+
+ var postContentList = new List<string> { "a", "b", "c", "d" };
+ var posts = new List<TimelinePostInfo>();
+
+ foreach (var (content, index) in postContentList.Select((v, i) => (v, i)))
+ {
+ var res = await client.PostAsJsonAsync(urlGenerator(1, "posts"),
+ new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
+ var post = res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<TimelinePostInfo>().Which;
+ posts.Add(post);
+ await Task.Delay(1000);
+ }
+
+ {
+ var res = await client.DeleteAsync(urlGenerator(1, $"posts/{posts[2].Id}"));
+ res.Should().BeDelete(true);
+ }
+
+ {
+
+ var res = await client.GetAsync(urlGenerator(1, "posts",
+ new Dictionary<string, string> {
+ { "modifiedSince", posts[1].LastUpdated.ToString("s", CultureInfo.InvariantCulture) },
+ { "includeDeleted", "true" }
+ }));
+ posts = res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<List<TimelinePostInfo>>()
+ .Which;
+ posts.Should().HaveCount(3);
+ posts.Select(p => p.Deleted).Should().Equal(false, true, false);
+ posts.Select(p => p.Content == null).Should().Equal(false, true, false);
+ }
+ }
}
}
|