ExpandUrlHtmlAsync() public méthode

HTML内に含まれるリンクのURLを非同期に展開する
public ExpandUrlHtmlAsync ( string html ) : Task
html string 処理対象のHTML
Résultat Task
Exemple #1
0
        public async Task ExpandUrlHtmlAsync_RelativeUriTest()
        {
            var handler = new HttpMessageHandlerMock();

            using (var http = new HttpClient(handler))
            {
                var shortUrl = new ShortUrl(http);

                handler.Enqueue(x =>
                {
                    // リクエストは送信されないはず
                    Assert.True(false);
                    return(this.CreateRedirectResponse("http://example.com/hoge"));
                });

                Assert.Equal("<a href=\"./hoge\">hogehoge</a>",
                             await shortUrl.ExpandUrlHtmlAsync("<a href=\"./hoge\">hogehoge</a>"));

                Assert.Equal(1, handler.QueueCount);
            }
        }
Exemple #2
0
        public async Task ExpandUrlHtmlAsync_Test()
        {
            var handler = new HttpMessageHandlerMock();

            using (var http = new HttpClient(handler))
            {
                var shortUrl = new ShortUrl(http);

                // https://t.co/hoge1 -> http://example.com/hoge2
                handler.Enqueue(x =>
                {
                    Assert.Equal(HttpMethod.Head, x.Method);
                    Assert.Equal(new Uri("https://t.co/hoge1"), x.RequestUri);

                    return(this.CreateRedirectResponse("http://example.com/hoge2"));
                });

                Assert.Equal("<a href=\"http://example.com/hoge2\">hogehoge</a>",
                             await shortUrl.ExpandUrlHtmlAsync("<a href=\"https://t.co/hoge1\">hogehoge</a>"));

                Assert.Equal(0, handler.QueueCount);
            }
        }
Exemple #3
0
        public async Task ExpandUrlHtmlAsync_RelativeUriTest()
        {
            var handler = new HttpMessageHandlerMock();
            using (var http = new HttpClient(handler))
            {
                var shortUrl = new ShortUrl(http);

                handler.Enqueue(x =>
                {
                    // リクエストは送信されないはず
                    Assert.True(false);
                    return this.CreateRedirectResponse("http://example.com/hoge");
                });

                Assert.Equal("<a href=\"./hoge\">hogehoge</a>",
                    await shortUrl.ExpandUrlHtmlAsync("<a href=\"./hoge\">hogehoge</a>"));

                Assert.Equal(1, handler.QueueCount);
            }
        }
Exemple #4
0
        public async Task ExpandUrlHtmlAsync_Test()
        {
            var handler = new HttpMessageHandlerMock();
            using (var http = new HttpClient(handler))
            {
                var shortUrl = new ShortUrl(http);

                // http://t.co/hoge1 -> http://example.com/hoge2
                handler.Enqueue(x =>
                {
                    Assert.Equal(HttpMethod.Head, x.Method);
                    Assert.Equal(new Uri("http://t.co/hoge1"), x.RequestUri);

                    return this.CreateRedirectResponse("http://example.com/hoge2");
                });

                Assert.Equal("<a href=\"http://example.com/hoge2\">hogehoge</a>",
                    await shortUrl.ExpandUrlHtmlAsync("<a href=\"http://t.co/hoge1\">hogehoge</a>"));

                Assert.Equal(0, handler.QueueCount);
            }
        }