OSDN Git Service

C# 8.0 のnull許容参照型を有効化
[opentween/open-tween.git] / OpenTween.Tests / Thumbnail / Services / TinamiTest.cs
index a8ac1da..5e2e6c9 100644 (file)
@@ -29,7 +29,8 @@ using System.Text.RegularExpressions;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Xml.Linq;
-using NSubstitute;
+using Moq;
+using OpenTween.Models;
 using Xunit;
 using Xunit.Extensions;
 
@@ -39,7 +40,7 @@ namespace OpenTween.Thumbnail.Services
     {
         class TestTinami : Tinami
         {
-            public string FakeXml { get; set; }
+            public string FakeXml { get; set; } = "";
 
             public TestTinami()
                 : base(null)
@@ -47,9 +48,7 @@ namespace OpenTween.Thumbnail.Services
             }
 
             protected override Task<XDocument> FetchContentInfoApiAsync(string contentId, CancellationToken token)
-            {
-                return Task.FromResult(XDocument.Parse(this.FakeXml));
-            }
+                => Task.FromResult(XDocument.Parse(this.FakeXml));
         }
 
         [Fact]
@@ -72,11 +71,11 @@ namespace OpenTween.Thumbnail.Services
     </image>
   </content>
 </rsp>";
-            var thumbinfo = await service.GetThumbnailInfoAsync("http://www.tinami.com/view/12345", null, CancellationToken.None);
+            var thumbinfo = await service.GetThumbnailInfoAsync("http://www.tinami.com/view/12345", new PostClass(), CancellationToken.None);
 
             Assert.NotNull(thumbinfo);
-            Assert.Equal("http://www.tinami.com/view/12345", thumbinfo.ImageUrl);
-            Assert.Equal("http://img.tinami.com/hogehoge_150.gif", thumbinfo.ThumbnailUrl);
+            Assert.Equal("http://www.tinami.com/view/12345", thumbinfo!.MediaPageUrl);
+            Assert.Equal("http://img.tinami.com/hogehoge_150.gif", thumbinfo.ThumbnailImageUrl);
             Assert.Equal("説明", thumbinfo.TooltipText);
         }
 
@@ -89,7 +88,7 @@ namespace OpenTween.Thumbnail.Services
 <rsp stat='user_only'>
   <err msg='この作品は登録ユーザー限定の作品です。'/>
 </rsp>";
-            var thumbinfo = await service.GetThumbnailInfoAsync("http://www.tinami.com/view/12345", null, CancellationToken.None);
+            var thumbinfo = await service.GetThumbnailInfoAsync("http://www.tinami.com/view/12345", new PostClass(), CancellationToken.None);
 
             Assert.Null(thumbinfo);
         }