diff options
author | crupest <crupest@outlook.com> | 2021-02-08 21:40:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 21:40:18 +0800 |
commit | e62cf8eb79c8b99eeff41a47b489af1ecde4fe49 (patch) | |
tree | 19511644c678f7bbb67d1b5aa14e5bd234f40c1f /BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs | |
parent | e6ccb7b00c1433197bec872a47cd68ea81c44d7b (diff) | |
parent | 45b683d582d4a7760ffd69c4cd47841ce0545119 (diff) | |
download | timeline-e62cf8eb79c8b99eeff41a47b489af1ecde4fe49.tar.gz timeline-e62cf8eb79c8b99eeff41a47b489af1ecde4fe49.tar.bz2 timeline-e62cf8eb79c8b99eeff41a47b489af1ecde4fe49.zip |
Merge pull request #245 from crupest/post
Backend: post get and patch.
Diffstat (limited to 'BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs index f05ed7af..17c85f22 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs @@ -491,6 +491,8 @@ namespace Timeline.Tests.IntegratedTests Color = "#1"
});
+ long id;
+
{
var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", new HttpTimelinePostCreateRequest
{
@@ -498,7 +500,70 @@ namespace Timeline.Tests.IntegratedTests Color = "#aabbcc"
});
post.Color.Should().Be("#aabbcc");
+ id = post.Id;
+ }
+
+ {
+ var post = await client.TestGetAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts/{id}");
+ post.Color.Should().Be("#aabbcc");
}
}
+
+ [Theory]
+ [MemberData(nameof(TimelineNameGeneratorTestData))]
+ public async Task GetPost(TimelineNameGenerator generator)
+ {
+ using var client = await CreateClientAsUser();
+
+ HttpTimelinePostCreateRequestContent CreateRequestContent() => new()
+ {
+ Type = "text",
+ Text = "aaa"
+ };
+
+ await client.TestGetAssertNotFoundAsync($"timelines/{generator(1)}/posts/1");
+
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", new HttpTimelinePostCreateRequest
+ {
+ Content = CreateRequestContent(),
+ });
+
+ var post2 = await client.TestGetAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts/{post.Id}");
+ post2.Should().BeEquivalentTo(post);
+
+ await client.TestDeleteAsync($"timelines/{generator(1)}/posts/{post.Id}");
+
+ await client.TestGetAssertNotFoundAsync($"timelines/{generator(1)}/posts/{post.Id}");
+ }
+
+ [Theory]
+ [MemberData(nameof(TimelineNameGeneratorTestData))]
+ public async Task PatchPost(TimelineNameGenerator generator)
+ {
+ using var client = await CreateClientAsUser();
+
+ var post = await client.TestPostAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts", new HttpTimelinePostCreateRequest
+ {
+ Content = new()
+ {
+ Type = "text",
+ Text = "aaa"
+ }
+ });
+
+ var date = new DateTime(2000, 10, 1);
+
+ var post2 = await client.TestPatchAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts/{post.Id}", new HttpTimelinePostPatchRequest
+ {
+ Time = date,
+ Color = "#aabbcc"
+ });
+ post2.Time.Should().Be(date);
+ post2.Color.Should().Be("#aabbcc");
+
+ var post3 = await client.TestGetAsync<HttpTimelinePost>($"timelines/{generator(1)}/posts/{post.Id}");
+ post3.Time.Should().Be(date);
+ post3.Color.Should().Be("#aabbcc");
+ }
}
}
|