aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-08 21:40:18 +0800
committerGitHub <noreply@github.com>2021-02-08 21:40:18 +0800
commit7978a4c8597a152e002516692fedb182a18fcae1 (patch)
treee021e03cd42eee6fa60b2f9a9d88bd9d2a30df9c /BackEnd/Timeline.Tests/IntegratedTests/TimelinePostTest.cs
parentdfbcc4bbbd032ea648b4f42b66080fc0b0261ab3 (diff)
parent391f82e85d4a31f4a5022a24062083f00d16b3c8 (diff)
downloadtimeline-7978a4c8597a152e002516692fedb182a18fcae1.tar.gz
timeline-7978a4c8597a152e002516692fedb182a18fcae1.tar.bz2
timeline-7978a4c8597a152e002516692fedb182a18fcae1.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.cs65
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");
+ }
}
}