GetTextLengthRemain() public method

public GetTextLengthRemain ( string postText ) : int
postText string
return int
Example #1
0
 public void GetTextLengthRemain_SurrogatePairTest()
 {
     using (var twitter = new Twitter())
     {
         Assert.Equal(139, twitter.GetTextLengthRemain("🍣"));
         Assert.Equal(133, twitter.GetTextLengthRemain("đŸ”„đŸ”đŸ”„ ç„Œăéł„"));
     }
 }
Example #2
0
        public void GetTextLengthRemain_UrlWithoutSchemeTest()
        {
            using (var twitter = new Twitter())
            {
                // t.co ă«çŸ­çžźă•ă‚Œă‚‹ćˆ†ăźæ–‡ć­—æ•°ă‚’è€ƒæ…ź
                twitter.Configuration.ShortUrlLength = 20;
                Assert.Equal(120, twitter.GetTextLengthRemain("example.com"));
                Assert.Equal(120, twitter.GetTextLengthRemain("example.com/hogehoge"));
                Assert.Equal(111, twitter.GetTextLengthRemain("hogehoge example.com"));

                // ă‚čă‚­ăƒŒăƒ  (http://) ă‚’çœç•„ă‹ă€æœ«ć°ŸăŒ ccTLD た栎搈は t.co ă«çŸ­çžźă•ă‚ŒăȘい
                Assert.Equal(130, twitter.GetTextLengthRemain("example.jp"));
                // ăŸă ă—ă€æœ«ć°Ÿă«ăƒ‘ă‚čăŒç¶šăć ŽćˆăŻ t.co ă«çŸ­çžźă•ă‚Œă‚‹
                Assert.Equal(120, twitter.GetTextLengthRemain("example.jp/hogehoge"));
            }
        }
Example #3
0
        public void GetTextLengthRemain_DirectMessageTest()
        {
            using (var twitter = new Twitter())
            {
                // 2015ćčŽ8æœˆă‹ă‚‰ DM ăźæ–‡ć­—æ•°äžŠé™ăŒ 10,000 æ–‡ć­—ă«ć€‰æ›Žă•ă‚ŒăŸ
                // https://twittercommunity.com/t/41348
                twitter.Configuration.DmTextCharacterLimit = 10000;

                Assert.Equal(10000, twitter.GetTextLengthRemain("D twitter "));
                Assert.Equal(9992, twitter.GetTextLengthRemain("D twitter hogehoge"));
            }
        }
Example #4
0
        public void GetTextLengthRemain_UrlTest()
        {
            using (var twitter = new Twitter())
            {
                // t.co ă«çŸ­çžźă•ă‚Œă‚‹ćˆ†ăźæ–‡ć­—æ•°ă‚’è€ƒæ…ź
                twitter.Configuration.ShortUrlLength = 20;
                Assert.Equal(120, twitter.GetTextLengthRemain("http://example.com/"));
                Assert.Equal(120, twitter.GetTextLengthRemain("http://example.com/hogehoge"));
                Assert.Equal(111, twitter.GetTextLengthRemain("hogehoge http://example.com/"));

                twitter.Configuration.ShortUrlLengthHttps = 21;
                Assert.Equal(119, twitter.GetTextLengthRemain("https://example.com/"));
                Assert.Equal(119, twitter.GetTextLengthRemain("https://example.com/hogehoge"));
                Assert.Equal(110, twitter.GetTextLengthRemain("hogehoge https://example.com/"));
            }
        }
Example #5
0
 public void GetTextLengthRemain_Test()
 {
     using (var twitter = new Twitter())
     {
         Assert.Equal(140, twitter.GetTextLengthRemain(""));
         Assert.Equal(132, twitter.GetTextLengthRemain("hogehoge"));
     }
 }