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 | 09835ee6432ad5eaaa2cc267c02b7586118ca705 (patch) | |
tree | dec6077d79be8e3fa0a6419080d10985b4049204 /Timeline.Tests/IntegratedTests/TimelineTest.cs | |
parent | 95be9f58b7cf76f1c585791447e8393d61862e1c (diff) | |
download | timeline-09835ee6432ad5eaaa2cc267c02b7586118ca705.tar.gz timeline-09835ee6432ad5eaaa2cc267c02b7586118ca705.tar.bz2 timeline-09835ee6432ad5eaaa2cc267c02b7586118ca705.zip |
Add invalid model tests.
Diffstat (limited to 'Timeline.Tests/IntegratedTests/TimelineTest.cs')
-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();
+ }
+ }
}
}
|