diff options
author | crupest <crupest@outlook.com> | 2020-11-15 17:38:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-15 17:38:10 +0800 |
commit | fa7b123be84afe020fc582535cc270e8cf24e85b (patch) | |
tree | 58d88a6412f718c1d6b304d7ee9580eaf1ab6c3a /BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs | |
parent | 379b4bafe982a8a8cd3158f0a9fa38a563dbdb57 (diff) | |
parent | 9f9f02c94f1248ecf02860a6c90c2ee1e2992c46 (diff) | |
download | timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.tar.gz timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.tar.bz2 timeline-fa7b123be84afe020fc582535cc270e8cf24e85b.zip |
Merge pull request #186 from crupest/unittest
Refactor unit tests.
Diffstat (limited to 'BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs b/BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs index 73fdd32f..5f2c20e8 100644 --- a/BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs +++ b/BackEnd/Timeline.Tests/Services/TimelineServiceTest.cs @@ -22,19 +22,15 @@ namespace Timeline.Tests.Services private readonly TestClock _clock = new TestClock();
- private DataManager _dataManager;
+ private DataManager _dataManager = default!;
- private UserPermissionService _userPermissionService;
+ private UserPermissionService _userPermissionService = default!;
- private UserService _userService;
+ private UserService _userService = default!;
- private TimelineService _timelineService;
+ private TimelineService _timelineService = default!;
- private UserDeleteService _userDeleteService;
-
- public TimelineServiceTest()
- {
- }
+ private UserDeleteService _userDeleteService = default!;
protected override void OnDatabaseCreated()
{
@@ -140,7 +136,7 @@ namespace Timeline.Tests.Services var posts = await _timelineService.GetPosts(timelineName, testPoint);
posts.Should().HaveCount(3)
- .And.Subject.Select(p => (p.Content as TextTimelinePostContent).Text).Should().Equal(postContentList.Skip(1));
+ .And.Subject.Select(p => ((TextTimelinePostContent)p.Content!).Text).Should().Equal(postContentList.Skip(1));
}
[Theory]
@@ -164,7 +160,7 @@ namespace Timeline.Tests.Services var posts = await _timelineService.GetPosts(timelineName);
posts.Should().HaveCount(4);
posts.Select(p => p.Deleted).Should().Equal(Enumerable.Repeat(false, posts.Count));
- posts.Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(postContentList);
+ posts.Select(p => ((TextTimelinePostContent)p.Content!).Text).Should().Equal(postContentList);
foreach (var id in new long[] { posts[0].Id, posts[2].Id })
{
@@ -174,12 +170,12 @@ namespace Timeline.Tests.Services posts = await _timelineService.GetPosts(timelineName);
posts.Should().HaveCount(2);
posts.Select(p => p.Deleted).Should().Equal(Enumerable.Repeat(false, posts.Count));
- posts.Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(new string[] { "b", "d" });
+ posts.Select(p => ((TextTimelinePostContent)p.Content!).Text).Should().Equal(new string[] { "b", "d" });
posts = await _timelineService.GetPosts(timelineName, includeDeleted: true);
posts.Should().HaveCount(4);
posts.Select(p => p.Deleted).Should().Equal(new bool[] { true, false, true, false });
- posts.Where(p => !p.Deleted).Select(p => ((TextTimelinePostContent)p.Content).Text).Should().Equal(new string[] { "b", "d" });
+ posts.Where(p => !p.Deleted).Select(p => ((TextTimelinePostContent)p.Content!).Text).Should().Equal(new string[] { "b", "d" });
}
[Theory]
|