From d089ad8774e5a6fbe0cd138e84c2a4af1e6a29af Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 11 Mar 2020 23:21:37 +0800 Subject: Add links test for timeline. --- Timeline.Tests/IntegratedTests/TimelineTest.cs | 36 +++++++++++++++++----- .../Helpers/StringLocalizerFactoryExtensions.cs | 19 ------------ 2 files changed, 28 insertions(+), 27 deletions(-) delete mode 100644 Timeline/Helpers/StringLocalizerFactoryExtensions.cs diff --git a/Timeline.Tests/IntegratedTests/TimelineTest.cs b/Timeline.Tests/IntegratedTests/TimelineTest.cs index 69a04003..215dcf17 100644 --- a/Timeline.Tests/IntegratedTests/TimelineTest.cs +++ b/Timeline.Tests/IntegratedTests/TimelineTest.cs @@ -98,16 +98,36 @@ namespace Timeline.Tests.IntegratedTests } [Fact] - public async Task Personal_TimelineGet_Should_Work() + public async Task TimelineGet_Should_Work() { using var client = await CreateDefaultClient(); - var res = await client.GetAsync("timelines/@user1"); - var body = res.Should().HaveStatusCode(200) - .And.HaveJsonBody().Which; - body.Owner.Should().BeEquivalentTo(UserInfos[1]); - body.Visibility.Should().Be(TimelineVisibility.Register); - body.Description.Should().Be(""); - body.Members.Should().NotBeNull().And.BeEmpty(); + { + var res = await client.GetAsync("timelines/@user1"); + var body = res.Should().HaveStatusCode(200) + .And.HaveJsonBody().Which; + body.Owner.Should().BeEquivalentTo(UserInfos[1]); + body.Visibility.Should().Be(TimelineVisibility.Register); + body.Description.Should().Be(""); + body.Members.Should().NotBeNull().And.BeEmpty(); + var links = body._links; + links.Should().NotBeNull(); + links.Self.Should().EndWith("/timelines/@user1"); + links.Posts.Should().EndWith("/timelines/@user1/posts"); + } + + { + var res = await client.GetAsync("timelines/t1"); + var body = res.Should().HaveStatusCode(200) + .And.HaveJsonBody().Which; + body.Owner.Should().BeEquivalentTo(UserInfos[1]); + body.Visibility.Should().Be(TimelineVisibility.Register); + body.Description.Should().Be(""); + body.Members.Should().NotBeNull().And.BeEmpty(); + var links = body._links; + links.Should().NotBeNull(); + links.Self.Should().EndWith("/timelines/t1"); + links.Posts.Should().EndWith("/timelines/t1/posts"); + } } [Fact] diff --git a/Timeline/Helpers/StringLocalizerFactoryExtensions.cs b/Timeline/Helpers/StringLocalizerFactoryExtensions.cs deleted file mode 100644 index c2252b2c..00000000 --- a/Timeline/Helpers/StringLocalizerFactoryExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ - -using Microsoft.Extensions.Localization; -using System.Reflection; - -namespace Timeline.Helpers -{ - internal static class StringLocalizerFactoryExtensions - { - internal static IStringLocalizer Create(this IStringLocalizerFactory factory, string basename) - { - return factory.Create(basename, new AssemblyName(typeof(StringLocalizerFactoryExtensions).Assembly.FullName!).Name); - } - - internal static StringLocalizer Create(this IStringLocalizerFactory factory) - { - return new StringLocalizer(factory); - } - } -} \ No newline at end of file -- cgit v1.2.3