示例#1
0
        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);
        }
示例#3
0
        public async Task NotMatchTest()
        {
            var service   = new TestImgAzyobuziNet();
            var thumbinfo = await service.GetThumbnailInfoAsync("http://hogehoge.com/abcd", null, CancellationToken.None);

            Assert.Null(thumbinfo);
        }
示例#4
0
        public void NotMatchTest()
        {
            var service = new TestImgAzyobuziNet();
            var thumbinfo = service.GetThumbnailInfo("http://hogehoge.com/abcd", null);

            Assert.That(thumbinfo, Is.Null);
        }
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        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);
        }
示例#13
0
        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 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);
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }
示例#17
0
        public async Task NotMatchTest()
        {
            var service = new TestImgAzyobuziNet();
            var thumbinfo = await service.GetThumbnailInfoAsync("http://hogehoge.com/abcd", null, CancellationToken.None);

            Assert.Null(thumbinfo);
        }
示例#18
0
        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);
        }
示例#19
0
        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);
        }
示例#20
0
        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);
        }