diff options
author | crupest <crupest@outlook.com> | 2020-07-10 20:18:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-07-10 20:18:08 +0800 |
commit | 94f64bd98a267360a9e941b86c56c614605067f2 (patch) | |
tree | 1f3229b149497657e37830e7042f4c4f09b61105 /Timeline.Tests/IntegratedTests/TimelineTest.cs | |
parent | f93ac5c1b21f9bee827c51955bd831ce0d322aaf (diff) | |
download | timeline-94f64bd98a267360a9e941b86c56c614605067f2.tar.gz timeline-94f64bd98a267360a9e941b86c56c614605067f2.tar.bz2 timeline-94f64bd98a267360a9e941b86c56c614605067f2.zip |
Add http api and integrated tests.
Diffstat (limited to 'Timeline.Tests/IntegratedTests/TimelineTest.cs')
-rw-r--r-- | Timeline.Tests/IntegratedTests/TimelineTest.cs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Timeline.Tests/IntegratedTests/TimelineTest.cs b/Timeline.Tests/IntegratedTests/TimelineTest.cs index 64619864..4ba8800e 100644 --- a/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -1255,5 +1255,39 @@ namespace Timeline.Tests.IntegratedTests .And.Subject.Select(p => p.Content.Text).Should().Equal(postContentList.Skip(1));
}
}
+
+ [Theory]
+ [MemberData(nameof(TimelineUrlGeneratorData))]
+ public async Task PostList_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 in postContentList)
+ {
+ var res = await client.PostAsJsonAsync(urlGenerator(1, "posts"),
+ new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Text = content, Type = TimelinePostContentTypes.Text } });
+ posts.Add(res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<TimelinePostInfo>().Which);
+ }
+
+ foreach (var id in new long[] { posts[0].Id, posts[2].Id })
+ {
+ var res = await client.DeleteAsync(urlGenerator(1, $"posts/{id}"));
+ res.Should().BeDelete(true);
+ }
+
+ {
+ var res = await client.GetAsync(urlGenerator(1, "posts", new Dictionary<string, string> { ["includeDeleted"] = "true" }));
+ posts = res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<List<TimelinePostInfo>>()
+ .Which;
+ posts.Should().HaveCount(4);
+ posts.Select(p => p.Deleted).Should().Equal(true, false, true, false);
+ posts.Select(p => p.Content == null).Should().Equal(true, false, true, false);
+ }
+ }
}
}
|