aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/IntegratedTests
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-10 22:27:30 +0800
committercrupest <crupest@outlook.com>2020-03-10 22:27:30 +0800
commit706eb877178d9c7f41b93927dedfc6c7ff27b7fd (patch)
treedec6077d79be8e3fa0a6419080d10985b4049204 /Timeline.Tests/IntegratedTests
parent5eaacedda31da86116f25158bd07e5ad8954e7b2 (diff)
downloadtimeline-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.cs45
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();
+ }
+ }
}
}