diff options
author | crupest <crupest@outlook.com> | 2021-01-07 16:23:20 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-01-07 16:23:20 +0800 |
commit | 7594a16e38304739487b053405153379faee6e58 (patch) | |
tree | bb99d1a24fffc9c4142219b9c25dc66e3d2b60d2 /BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs | |
parent | 97e094c97dc9ed79cf7daa0a93568e1933015bdd (diff) | |
download | timeline-7594a16e38304739487b053405153379faee6e58.tar.gz timeline-7594a16e38304739487b053405153379faee6e58.tar.bz2 timeline-7594a16e38304739487b053405153379faee6e58.zip |
史诗级重构!
Diffstat (limited to 'BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs')
-rw-r--r-- | BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs b/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs deleted file mode 100644 index 849936ec..00000000 --- a/BackEnd/Timeline.Tests/Services/BookmarkTimelineServiceTest.cs +++ /dev/null @@ -1,102 +0,0 @@ -using FluentAssertions;
-using Microsoft.Extensions.Logging.Abstractions;
-using System.Threading.Tasks;
-using Timeline.Services;
-using Timeline.Tests.Helpers;
-using Xunit;
-
-namespace Timeline.Tests.Services
-{
- public class BookmarkTimelineServiceTest : DatabaseBasedTest
- {
- private BookmarkTimelineService _service = default!;
- private UserService _userService = default!;
- private TimelineService _timelineService = default!;
-
- protected override void OnDatabaseCreated()
- {
- var clock = new TestClock();
- _userService = new UserService(NullLogger<UserService>.Instance, Database, new PasswordService(), new UserPermissionService(Database), clock);
- _timelineService = new TimelineService(Database, _userService, clock);
- _service = new BookmarkTimelineService(Database, _userService, _timelineService);
- }
-
- [Fact]
- public async Task Should_Work()
- {
- var userId = await _userService.GetUserIdByUsername("user");
-
- {
- var b = await _service.GetBookmarks(userId);
- b.Should().BeEmpty();
- }
-
- await _timelineService.CreateTimeline("tl", userId);
- await _service.AddBookmark(userId, "tl");
-
- {
- var b = await _service.GetBookmarks(userId);
- b.Should().HaveCount(1).And.BeEquivalentTo(await _timelineService.GetTimeline("tl"));
- }
- }
-
- [Fact]
- public async Task NewOne_Should_BeAtLast()
- {
- var userId = await _userService.GetUserIdByUsername("user");
- await _timelineService.CreateTimeline("t1", userId);
- await _service.AddBookmark(userId, "t1");
-
- await _timelineService.CreateTimeline("t2", userId);
- await _service.AddBookmark(userId, "t2");
-
- var b = await _service.GetBookmarks(userId);
-
- b.Should().HaveCount(2);
- b[0].Name.Should().Be("t1");
- b[1].Name.Should().Be("t2");
- }
-
- [Fact]
- public async Task Multiple_Should_Work()
- {
- var userId = await _userService.GetUserIdByUsername("user");
-
- // make timeline id not same as entity id.
- await _timelineService.CreateTimeline("t0", userId);
-
- await _timelineService.CreateTimeline("t1", userId);
- await _service.AddBookmark(userId, "t1");
-
- await _timelineService.CreateTimeline("t2", userId);
- await _service.AddBookmark(userId, "t2");
-
- await _timelineService.CreateTimeline("t3", userId);
- await _service.AddBookmark(userId, "t3");
-
- await _service.MoveBookmark(userId, "t3", 2);
- (await _service.GetBookmarks(userId))[1].Name.Should().Be("t3");
-
- await _service.MoveBookmark(userId, "t1", 3);
- (await _service.GetBookmarks(userId))[2].Name.Should().Be("t1");
-
- await _service.RemoveBookmark(userId, "t2");
- await _service.RemoveBookmark(userId, "t1");
- await _service.RemoveBookmark(userId, "t3");
- (await _service.GetBookmarks(userId)).Should().BeEmpty();
- }
-
- [Fact]
- public async Task AddExist_Should_DoNothing()
- {
- var userId = await _userService.GetUserIdByUsername("user");
-
- await _timelineService.CreateTimeline("t", userId);
-
- await _service.AddBookmark(userId, "t");
- await _service.AddBookmark(userId, "t");
-
- (await _service.GetBookmarks(userId)).Should().HaveCount(1);
- }
- }
-}
|