Beispiel #1
0
        public void TweetIdCanBeExtractedFromUrl()
        {
            // Arrange
            var testCases = new Dictionary <string, ulong>
            {
                { "https://twitter.com/TweetAngi/status/733279889596514304", 733279889596514304 },
                { "https://twitter.com/dqmhose/status/733279824299630592", 733279824299630592 },
                { "https://twitter.com/anne_nymus/status/733274507339763712", 733274507339763712 },
                { "https://twitter.com/LaDolceVegas/status/725649743364370433", 725649743364370433 },
                { "https://twitter.com/ID_AA_Carmack/status/733275349048381440", 733275349048381440 },
                { "https://twitter.com/SPORT1/status/733273819994071040/", 733273819994071040 },
                { "https://twitter.com/NetflixDE/status/733279091869286400?variable=true", 733279091869286400 },
                { "https://pbs.twimg.com/media/Ci0gimSWEAASP-L.jpg", 0 },
                { "https://twitter.com", 0 },
                { "https://twitter.com/twitterapi", 0 }
            };

            // Act
            var results = testCases.ToDictionary(kvp => kvp.Key, kvp => TwitterHelper.ExtractTweetId(kvp.Key));

            // Assert
            foreach (var kvp in testCases)
            {
                Assert.AreEqual(kvp.Value, results[kvp.Key], kvp.Key);
            }
        }
Beispiel #2
0
        public ulong ExtractQuotedTweetUrl()
        {
            var quoteUrl = Model?.Entities?.UrlEntities?.FirstOrDefault(e => TwitterHelper.IsTweetUrl(e.ExpandedUrl));

            return(quoteUrl == null
                                ? 0
                                : TwitterHelper.ExtractTweetId(quoteUrl.ExpandedUrl));
        }
Beispiel #3
0
        public ulong ExtractQuotedTweetUrl()
        {
            var quoteUrl = Model?.Entities?.UrlEntities?.SingleOrDefault(e => TwitterHelper.IsTweetUrl(e.ExpandedUrl));

            if (quoteUrl == null)
            {
                return(0);
            }

            return(TwitterHelper.ExtractTweetId(quoteUrl.ExpandedUrl));
        }