コード例 #1
0
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
        {
            var account = value[1] as AccountContainer;

            return((account?.MaxTweetLength - account?.CountText(value[0] as string))?.ToString() ??
                   (280 - TwitterAccount.CountTextStatic(value[0] as string)).ToString());
        }
コード例 #2
0
        public void TestTweetCounter()
        {
            var tweetcounter = new TweetCounter();
            //should be 8
            var yabuki_kana = "矢吹可奈";

            Assert.AreEqual(TwitterAccount.CountTextStatic(yabuki_kana), 8);
            //should be 1
            Assert.AreEqual(TwitterAccount.CountTextStatic(Environment.NewLine), 1);
            //should be 14
            var tokugawa_matsuri =
                $"徳{Environment.NewLine}川{Environment.NewLine}ま{Environment.NewLine}つ{Environment.NewLine}り";

            Assert.AreEqual(TwitterAccount.CountTextStatic(tokugawa_matsuri), 10 + 4);
            //should be 224
            var yanyanokuresoudesu =
                "やんやんっ😖🐤遅れそうです😫🌀 たいへんっ⚡駅🚉までだっしゅ!🏃💨 初めて💕のデート💑ごめん🙇で登場?💦やんやんっ🐦😥そんなのだめよ🙅たいへんっ😰電車🚃よいそげ!🙏♥ 不安な気持ち😞がすっぱい⚡😖😖ぶる~べりぃ💜とれいん 💖🐣💚";

            Assert.AreEqual(TwitterAccount.CountTextStatic(yanyanokuresoudesu), 114 * 2 - 4);
        }