public async Task HostFallbackTest() { var service = new TestImgAzyobuziNet(new[] { "http://avail1.example.com/api/", "http://avail2.example.com/api/" }); await service.LoadRegexAsync(); Assert.Equal("http://avail1.example.com/api/", service.GetApiBase()); service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/", "http://avail.example.com/api/" }); await service.LoadRegexAsync(); Assert.Equal("http://avail.example.com/api/", service.GetApiBase()); service = new TestImgAzyobuziNet(new[] { "http://error.example.com/api/", "http://avail.example.com/api/" }); await service.LoadRegexAsync(); Assert.Equal("http://avail.example.com/api/", service.GetApiBase()); service = new TestImgAzyobuziNet(new[] { "http://invalid.example.com/api/", "http://avail.example.com/api/" }); await service.LoadRegexAsync(); Assert.Equal("http://avail.example.com/api/", service.GetApiBase()); service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/" }); await service.LoadRegexAsync(); Assert.Null(service.GetApiBase()); }
public void NotMatchTest() { var service = new TestImgAzyobuziNet(); var thumbinfo = service.GetThumbnailInfo("http://hogehoge.com/abcd", null); Assert.That(thumbinfo, Is.Null); }
public async Task NotMatchTest() { var service = new TestImgAzyobuziNet(); var thumbinfo = await service.GetThumbnailInfoAsync("http://hogehoge.com/abcd", null, CancellationToken.None); Assert.Null(thumbinfo); }
public void HostFallbackTest() { var service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/", "http://avail.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.EqualTo("http://avail.example.com/api/")); }
public void MatchTest() { var service = new TestImgAzyobuziNet(); var thumbinfo = service.GetThumbnailInfo("http://example.com/abcd", null); Assert.That(thumbinfo, Is.Not.Null); Assert.That(thumbinfo.ImageUrl, Is.EqualTo("http://example.com/abcd")); Assert.That(thumbinfo.ThumbnailUrl, Is.EqualTo("http://img.azyobuzi.net/api/redirect?size=large&uri=http%3A%2F%2Fexample.com%2Fabcd")); Assert.That(thumbinfo.TooltipText, Is.Null); }
public async Task Enabled_FalseTest() { var service = new TestImgAzyobuziNet(); service.Enabled = false; var thumbinfo = await service.GetThumbnailInfoAsync("http://example.com/abcd", null, CancellationToken.None); Assert.Null(thumbinfo); }
public async Task MatchTest() { var service = new TestImgAzyobuziNet(); var thumbinfo = await service.GetThumbnailInfoAsync("http://example.com/abcd", null, CancellationToken.None); Assert.NotNull(thumbinfo); Assert.Equal("http://example.com/abcd", thumbinfo.MediaPageUrl); Assert.Equal("http://img.azyobuzi.net/api/redirect?size=large&uri=http%3A%2F%2Fexample.com%2Fabcd", thumbinfo.ThumbnailImageUrl); Assert.Null(thumbinfo.TooltipText); }
public void ServerOutageTest() { var service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.Null); var thumbinfo = service.GetThumbnailInfo("http://example.com/abcd", null); Assert.That(thumbinfo, Is.Null); }
public async Task ServerOutageTest() { var service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/" }); await service.LoadRegexAsync(); Assert.Null(service.GetApiBase()); var thumbinfo = await service.GetThumbnailInfoAsync("http://example.com/abcd", null, CancellationToken.None); Assert.Null(thumbinfo); }
public async Task DisabledInDM_Test() { var service = new TestImgAzyobuziNet(); service.DisabledInDM = true; var post = new PostClass { TextFromApi = "http://example.com/abcd", IsDm = true, }; var thumbinfo = await service.GetThumbnailInfoAsync("http://example.com/abcd", post, CancellationToken.None); Assert.Null(thumbinfo); }
public void HostFallbackTest() { var service = new TestImgAzyobuziNet(new[] { "http://avail1.example.com/api/", "http://avail2.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.EqualTo("http://avail1.example.com/api/")); service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/", "http://avail.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.EqualTo("http://avail.example.com/api/")); service = new TestImgAzyobuziNet(new[] { "http://error.example.com/api/", "http://avail.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.EqualTo("http://avail.example.com/api/")); service = new TestImgAzyobuziNet(new[] { "http://invalid.example.com/api/", "http://avail.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.EqualTo("http://avail.example.com/api/")); service = new TestImgAzyobuziNet(new[] { "http://down.example.com/api/" }); service.LoadRegex(); Assert.That(service.GetApiBase(), Is.Null); }
public async Task MatchTest() { var service = new TestImgAzyobuziNet(); var thumbinfo = await service.GetThumbnailInfoAsync("http://example.com/abcd", null, CancellationToken.None); Assert.NotNull(thumbinfo); Assert.Equal("http://example.com/abcd", thumbinfo.ImageUrl); Assert.Equal("http://img.azyobuzi.net/api/redirect?size=large&uri=http%3A%2F%2Fexample.com%2Fabcd", thumbinfo.ThumbnailUrl); Assert.Null(thumbinfo.TooltipText); }