Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }