diff options
author | crupest <crupest@outlook.com> | 2020-03-10 22:27:30 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-10 22:27:30 +0800 |
commit | 706eb877178d9c7f41b93927dedfc6c7ff27b7fd (patch) | |
tree | dec6077d79be8e3fa0a6419080d10985b4049204 /Timeline.Tests/IntegratedTests | |
parent | 5eaacedda31da86116f25158bd07e5ad8954e7b2 (diff) | |
download | timeline-706eb877178d9c7f41b93927dedfc6c7ff27b7fd.tar.gz timeline-706eb877178d9c7f41b93927dedfc6c7ff27b7fd.tar.bz2 timeline-706eb877178d9c7f41b93927dedfc6c7ff27b7fd.zip |
Add invalid model tests.
Diffstat (limited to 'Timeline.Tests/IntegratedTests')
-rw-r--r-- | Timeline.Tests/IntegratedTests/TimelineTest.cs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Timeline.Tests/IntegratedTests/TimelineTest.cs b/Timeline.Tests/IntegratedTests/TimelineTest.cs index 3fceb1d5..5a721205 100644 --- a/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -909,5 +909,50 @@ namespace Timeline.Tests.IntegratedTests .Which.Select(p => p.Id).Should().Equal(id1, id2, id0);
}
}
+
+ [Fact]
+ public async Task CreatePost_InvalidModel()
+ {
+ await CreateTestTimelines();
+
+ using var client = await CreateClientAsUser();
+
+ {
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = null });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = null } });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "hahaha" } });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "text", Text = null } });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = null } });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ // image not base64
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = "!!!" } });
+ res.Should().BeInvalidModel();
+ }
+
+ {
+ // image base64 not image
+ var res = await client.PostAsJsonAsync("timelines/t1/posts", new TimelinePostCreateRequest { Content = new TimelinePostCreateRequestContent { Type = "image", Data = Convert.ToBase64String(new byte[] { 0x01, 0x02, 0x03 }) } });
+ res.Should().BeInvalidModel();
+ }
+ }
}
}
|