public void ExtractUrls_Test() { Assert.Equal(new[] { "http://example.com/" }, TweetExtractor.ExtractUrls("http://example.com/")); Assert.Equal(new[] { "http://example.com/hogehoge" }, TweetExtractor.ExtractUrls("http://example.com/hogehoge")); Assert.Equal(new[] { "http://example.com/" }, TweetExtractor.ExtractUrls("hogehoge http://example.com/")); Assert.Equal(new[] { "https://example.com/" }, TweetExtractor.ExtractUrls("https://example.com/")); Assert.Equal(new[] { "https://example.com/hogehoge" }, TweetExtractor.ExtractUrls("https://example.com/hogehoge")); Assert.Equal(new[] { "https://example.com/" }, TweetExtractor.ExtractUrls("hogehoge https://example.com/")); Assert.Equal(new[] { "example.com" }, TweetExtractor.ExtractUrls("example.com")); Assert.Equal(new[] { "example.com/hogehoge" }, TweetExtractor.ExtractUrls("example.com/hogehoge")); Assert.Equal(new[] { "example.com" }, TweetExtractor.ExtractUrls("hogehoge example.com")); // スキーム (http://) を省略かつ末尾が ccTLD の場合は t.co に短縮されない Assert.Empty(TweetExtractor.ExtractUrls("example.jp")); // ただし、末尾にパスが続く場合は t.co に短縮される Assert.Equal(new[] { "example.jp/hogehoge" }, TweetExtractor.ExtractUrls("example.jp/hogehoge")); }