diff options
author | crupest <crupest@outlook.com> | 2020-08-31 22:49:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-31 22:49:57 +0800 |
commit | 3e7e533016b04df4993df66842409cf5857983ee (patch) | |
tree | 187696f3303241177820ca65fa441655a03de257 /Timeline.Tests/Services/TimelineServiceTest.cs | |
parent | b2404a381178e962a09af018d3c0031f1918991a (diff) | |
parent | 7e414fb4a09e6d35fa32d48fdba38a537ffe1d23 (diff) | |
download | timeline-3e7e533016b04df4993df66842409cf5857983ee.tar.gz timeline-3e7e533016b04df4993df66842409cf5857983ee.tar.bz2 timeline-3e7e533016b04df4993df66842409cf5857983ee.zip |
Merge pull request #158 from crupest/dev
Develop new features of back end.
Diffstat (limited to 'Timeline.Tests/Services/TimelineServiceTest.cs')
-rw-r--r-- | Timeline.Tests/Services/TimelineServiceTest.cs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Timeline.Tests/Services/TimelineServiceTest.cs b/Timeline.Tests/Services/TimelineServiceTest.cs index 36e5ed0c..5a774b78 100644 --- a/Timeline.Tests/Services/TimelineServiceTest.cs +++ b/Timeline.Tests/Services/TimelineServiceTest.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Timeline.Entities;
using Timeline.Models;
using Timeline.Services;
+using Timeline.Services.Exceptions;
using Timeline.Tests.Helpers;
using Xunit;
@@ -271,5 +272,58 @@ namespace Timeline.Tests.Services posts.Should().HaveCount(4);
}
}
+
+ [Theory]
+ [InlineData("@admin")]
+ [InlineData("tl")]
+ public async Task Title(string timelineName)
+ {
+ var _ = TimelineHelper.ExtractTimelineName(timelineName, out var isPersonal);
+ if (!isPersonal)
+ await _timelineService.CreateTimeline(timelineName, await _userService.GetUserIdByUsername("user"));
+
+ {
+ var timeline = await _timelineService.GetTimeline(timelineName);
+ timeline.Title.Should().Be(timelineName);
+ }
+
+ {
+ await _timelineService.ChangeProperty(timelineName, new TimelineChangePropertyRequest { Title = null });
+ var timeline = await _timelineService.GetTimeline(timelineName);
+ timeline.Title.Should().Be(timelineName);
+ }
+
+ {
+ await _timelineService.ChangeProperty(timelineName, new TimelineChangePropertyRequest { Title = "atitle" });
+ var timeline = await _timelineService.GetTimeline(timelineName);
+ timeline.Title.Should().Be("atitle");
+ }
+ }
+
+ [Fact]
+ public async Task ChangeName()
+ {
+ _clock.ForwardCurrentTime();
+
+ await _timelineService.Awaiting(s => s.ChangeTimelineName("!!!", "newtl")).Should().ThrowAsync<ArgumentException>();
+ await _timelineService.Awaiting(s => s.ChangeTimelineName("tl", "!!!")).Should().ThrowAsync<ArgumentException>();
+ await _timelineService.Awaiting(s => s.ChangeTimelineName("tl", "newtl")).Should().ThrowAsync<TimelineNotExistException>();
+
+ await _timelineService.CreateTimeline("tl", await _userService.GetUserIdByUsername("user"));
+ await _timelineService.CreateTimeline("tl2", await _userService.GetUserIdByUsername("user"));
+
+ await _timelineService.Awaiting(s => s.ChangeTimelineName("tl", "tl2")).Should().ThrowAsync<EntityAlreadyExistException>();
+
+ var time = _clock.ForwardCurrentTime();
+
+ await _timelineService.ChangeTimelineName("tl", "newtl");
+
+ {
+ var timeline = await _timelineService.GetTimeline("newtl");
+ timeline.Name.Should().Be("newtl");
+ timeline.LastModified.Should().Be(time);
+ timeline.NameLastModified.Should().Be(time);
+ }
+ }
}
}
|