aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-11-18 19:43:33 +0800
committercrupest <crupest@outlook.com>2019-11-18 19:43:33 +0800
commit0b77c676b81d7340560b22fc6609740df98e9141 (patch)
tree6280d70a821b3b5248817c29c58c2365ad1f63d9
parent06a5d9aae4a348ff93aeaa40ac3d3ae2e7354f0f (diff)
downloadtimeline-0b77c676b81d7340560b22fc6609740df98e9141.tar.gz
timeline-0b77c676b81d7340560b22fc6609740df98e9141.tar.bz2
timeline-0b77c676b81d7340560b22fc6609740df98e9141.zip
Continue to write tests.
-rw-r--r--Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs49
-rw-r--r--Timeline/Models/Timeline.cs1
-rw-r--r--Timeline/Services/TimelineService.cs2
3 files changed, 50 insertions, 2 deletions
diff --git a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs
index aaa6215c..2e5b86fa 100644
--- a/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs
+++ b/Timeline.Tests/IntegratedTests/PersonalTimelineTest.cs
@@ -24,6 +24,55 @@ namespace Timeline.Tests.IntegratedTests
}
[Fact]
+ public async Task TimelineGet_Should_Work()
+ {
+ using var client = Factory.CreateDefaultClient();
+ var res = await client.GetAsync("users/user/timeline");
+ var body = res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<BaseTimelineInfo>().Which;
+ body.Owner.Should().Be("user");
+ body.Visibility.Should().Be(TimelineVisibility.Register);
+ body.Description.Should().Be("");
+ body.Members.Should().NotBeNull().And.BeEmpty();
+ }
+
+ [Fact]
+ public async Task Description_Should_Work()
+ {
+ using var client = await Factory.CreateClientAsUser();
+
+ async Task AssertDescription(string description)
+ {
+ var res = await client.GetAsync("users/user/timeline");
+ var body = res.Should().HaveStatusCode(200)
+ .And.HaveJsonBody<BaseTimelineInfo>()
+ .Which.Description.Should().Be(description);
+ }
+
+ const string mockDescription = "haha";
+
+ await AssertDescription("");
+ {
+ var res = await client.PostAsJsonAsync("users/user/timeline/op/property",
+ new TimelinePropertyChangeRequest { Description = mockDescription });
+ res.Should().HaveStatusCode(200);
+ await AssertDescription(mockDescription);
+ }
+ {
+ var res = await client.PostAsJsonAsync("users/user/timeline/op/property",
+ new TimelinePropertyChangeRequest { Description = null });
+ res.Should().HaveStatusCode(200);
+ await AssertDescription(mockDescription);
+ }
+ {
+ var res = await client.PostAsJsonAsync("users/user/timeline/op/property",
+ new TimelinePropertyChangeRequest { Description = "" });
+ res.Should().HaveStatusCode(200);
+ await AssertDescription("");
+ }
+ }
+
+ [Fact]
public async Task Member_Should_Work()
{
const string getUrl = "users/user/timeline";
diff --git a/Timeline/Models/Timeline.cs b/Timeline/Models/Timeline.cs
index 85fefff5..752c698d 100644
--- a/Timeline/Models/Timeline.cs
+++ b/Timeline/Models/Timeline.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using Timeline.Entities;
namespace Timeline.Models
{
diff --git a/Timeline/Services/TimelineService.cs b/Timeline/Services/TimelineService.cs
index 1d199aae..1e64353c 100644
--- a/Timeline/Services/TimelineService.cs
+++ b/Timeline/Services/TimelineService.cs
@@ -717,7 +717,7 @@ namespace Timeline.Services
return new BaseTimelineInfo
{
- Description = timelineEntity.Description,
+ Description = timelineEntity.Description ?? "",
Owner = username,
Visibility = timelineEntity.Visibility,
Members = memberUsernames.ToList()