Пример #1
0
        public void ProcessResults_Handles_RateLimits_Results()
        {
            var helpReqProc = new HelpRequestProcessor <Help>
            {
                Type    = HelpType.RateLimits,
                BaseUrl = "https://api.twitter.com/1.1/"
            };

            List <Help> helpList = helpReqProc.ProcessResults(RateLimitsResponse);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();

            Assert.AreEqual(HelpType.RateLimits, help.Type);
            Assert.AreEqual("15411837-3wGGrD7CY0Hb0tguLA3pSH7EMwSWWcnuD3DEQ1E27", help.RateLimitAccountContext);
            Assert.IsNotNull(help.RateLimits);
            Assert.IsTrue(help.RateLimits.Any());
            Dictionary <string, List <RateLimits> > rateLimits = help.RateLimits;

            Assert.IsTrue(rateLimits.ContainsKey("lists"));
            List <RateLimits> limitsList = rateLimits["lists"];

            Assert.IsNotNull(limitsList);
            Assert.IsTrue(limitsList.Any());
            RateLimits limits = limitsList.First();

            Assert.IsNotNull(limits);
            Assert.AreEqual("/lists/subscriptions", limits.Resource);
            Assert.AreEqual(15, limits.Limit);
            Assert.AreEqual(15, limits.Remaining);
            Assert.AreEqual(1348087186ul, limits.Reset);
        }
Пример #2
0
        public void ProcessResults_Handles_Languages_Results()
        {
            const int    ExpectedLanguagesCount = 28;
            const string ExpectedLanguageName   = "Hungarian";
            const string ExpectedLanguageStatus = "production";
            const string ExpectedLanguageCode   = "hu";
            var          helpReqProc            = new HelpRequestProcessor <Help>
            {
                Type    = HelpType.Languages,
                BaseUrl = "https://api.twitter.com/1.1/"
            };

            List <Help> helpList = helpReqProc.ProcessResults(HelpLanguagesXml);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();

            Assert.AreEqual(HelpType.Languages, help.Type);
            List <Language> languages = help.Languages;

            Assert.IsNotNull(languages);
            Assert.AreEqual(ExpectedLanguagesCount, languages.Count);
            Language language = languages.First();

            Assert.AreEqual(ExpectedLanguageName, language.Name);
            Assert.AreEqual(ExpectedLanguageStatus, language.Status);
            Assert.AreEqual(ExpectedLanguageCode, language.Code);
        }
Пример #3
0
        public void ProcessResults_Handles_Configuration_Results()
        {
            const int    ExpectedCharsRsvpPerMedia         = 21;
            const int    ExpectedPhotoSizesCount           = 4;
            const string ExpectedPhotoSizeType             = "thumb";
            const int    ExpectedPhotoSizeHeight           = 150;
            const int    ExpectedPhotoSizeWidth            = 150;
            const string ExpectedPhotoSizeResize           = "crop";
            const int    ExpectedShortUrlLength            = 20;
            const int    ExpectedPhotoSizeLimit            = 3145728;
            const int    ExpectedNonUsernamePathsCount     = 82;
            const string ExpectedNonUsernamePathsFirstItem = "about";
            const int    ExpectedMaxMediaPerUpload         = 1;
            const int    ExpectedShortUrlLengthHttps       = 21;
            var          helpReqProc = new HelpRequestProcessor <Help>
            {
                Type    = HelpType.Configuration,
                BaseUrl = "https://api.twitter.com/1.1/"
            };

            List <Help> helpList = helpReqProc.ProcessResults(HelpConfigurationResponse);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();

            Assert.AreEqual(HelpType.Configuration, help.Type);
            Assert.IsNotNull(help.Configuration);
            Configuration config = help.Configuration;

            Assert.AreEqual(ExpectedCharsRsvpPerMedia, config.CharactersReservedPerMedia);
            List <PhotoSize> photoSizes = config.PhotoSizes;

            Assert.IsNotNull(photoSizes);
            Assert.AreEqual(ExpectedPhotoSizesCount, photoSizes.Count);
            PhotoSize photoSize = photoSizes.First();

            Assert.AreEqual(ExpectedPhotoSizeType, photoSize.Type);
            Assert.AreEqual(ExpectedPhotoSizeHeight, photoSize.Height);
            Assert.AreEqual(ExpectedPhotoSizeWidth, photoSize.Width);
            Assert.AreEqual(ExpectedPhotoSizeResize, photoSize.Resize);
            Assert.AreEqual(ExpectedShortUrlLength, config.ShortUrlLength);
            Assert.AreEqual(ExpectedPhotoSizeLimit, config.PhotoSizeLimit);
            List <string> nonUsernamePaths = config.NonUserNamePaths;

            Assert.IsNotNull(nonUsernamePaths);
            Assert.AreEqual(ExpectedNonUsernamePathsCount, nonUsernamePaths.Count);
            Assert.AreEqual(ExpectedNonUsernamePathsFirstItem, nonUsernamePaths.First());
            Assert.AreEqual(ExpectedMaxMediaPerUpload, config.MaxMediaPerUpload);
            Assert.AreEqual(ExpectedShortUrlLengthHttps, config.ShortUrlLengthHttps);
        }
        public void ProcessResults_Handles_RateLimits_Results()
        {
            var helpReqProc = new HelpRequestProcessor<Help>
            {
                Type = HelpType.RateLimits,
                BaseUrl = "https://api.twitter.com/1.1/"
            };

            List<Help> helpList = helpReqProc.ProcessResults(RateLimitsResponse);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();
            Assert.AreEqual(HelpType.RateLimits, help.Type);
            Assert.AreEqual("15411837-3wGGrD7CY0Hb0tguLA3pSH7EMwSWWcnuD3DEQ1E27", help.RateLimitAccountContext);
            Assert.IsNotNull(help.RateLimits);
            Assert.IsTrue(help.RateLimits.Any());
            Dictionary<string, List<RateLimits>> rateLimits = help.RateLimits;
            Assert.IsTrue(rateLimits.ContainsKey("lists"));
            List<RateLimits> limitsList = rateLimits["lists"];
            Assert.IsNotNull(limitsList);
            Assert.IsTrue(limitsList.Any());
            RateLimits limits = limitsList.First();
            Assert.IsNotNull(limits);
            Assert.AreEqual("/lists/subscriptions", limits.Resource);
            Assert.AreEqual(15, limits.Limit);
            Assert.AreEqual(15, limits.Remaining);
            Assert.AreEqual(1348087186ul, limits.Reset);
        }
        public void ProcessResults_Handles_Languages_Results()
        {
            const int ExpectedLanguagesCount = 28;
            const string ExpectedLanguageName = "Hungarian";
            const string ExpectedLanguageStatus = "production";
            const string ExpectedLanguageCode = "hu";
            var helpReqProc = new HelpRequestProcessor<Help> 
            {
                Type = HelpType.Languages,
                BaseUrl = "https://api.twitter.com/1.1/" 
            };

            List<Help> helpList = helpReqProc.ProcessResults(HelpLanguagesXml);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();
            Assert.AreEqual(HelpType.Languages, help.Type);
            List<Language> languages = help.Languages;
            Assert.IsNotNull(languages);
            Assert.AreEqual(ExpectedLanguagesCount, languages.Count);
            Language language = languages.First();
            Assert.AreEqual(ExpectedLanguageName, language.Name);
            Assert.AreEqual(ExpectedLanguageStatus, language.Status);
            Assert.AreEqual(ExpectedLanguageCode, language.Code);
        }
        public void ProcessResults_Handles_Configuration_Results()
        {
            const int ExpectedCharsRsvpPerMedia = 21;
            const int ExpectedPhotoSizesCount = 4;
            const string ExpectedPhotoSizeType = "thumb";
            const int ExpectedPhotoSizeHeight = 150;
            const int ExpectedPhotoSizeWidth = 150;
            const string ExpectedPhotoSizeResize = "crop";
            const int ExpectedShortUrlLength = 20;
            const int ExpectedPhotoSizeLimit = 3145728;
            const int ExpectedNonUsernamePathsCount = 82;
            const string ExpectedNonUsernamePathsFirstItem = "about";
            const int ExpectedMaxMediaPerUpload = 1;
            const int ExpectedShortUrlLengthHttps = 21;
            var helpReqProc = new HelpRequestProcessor<Help> 
            {
                Type = HelpType.Configuration,
                BaseUrl = "https://api.twitter.com/1.1/" 
            };

            List<Help> helpList = helpReqProc.ProcessResults(HelpConfigurationResponse);

            Assert.IsNotNull(helpList);
            Assert.IsNotNull(helpList.SingleOrDefault());
            Help help = helpList.Single();
            Assert.AreEqual(HelpType.Configuration, help.Type);
            Assert.IsNotNull(help.Configuration);
            Configuration config = help.Configuration;
            Assert.AreEqual(ExpectedCharsRsvpPerMedia, config.CharactersReservedPerMedia);
            List<PhotoSize> photoSizes = config.PhotoSizes;
            Assert.IsNotNull(photoSizes);
            Assert.AreEqual(ExpectedPhotoSizesCount, photoSizes.Count);
            PhotoSize photoSize = photoSizes.First();
            Assert.AreEqual(ExpectedPhotoSizeType, photoSize.Type);
            Assert.AreEqual(ExpectedPhotoSizeHeight, photoSize.Height);
            Assert.AreEqual(ExpectedPhotoSizeWidth, photoSize.Width);
            Assert.AreEqual(ExpectedPhotoSizeResize, photoSize.Resize);
            Assert.AreEqual(ExpectedShortUrlLength, config.ShortUrlLength);
            Assert.AreEqual(ExpectedPhotoSizeLimit, config.PhotoSizeLimit);
            List<string> nonUsernamePaths = config.NonUserNamePaths;
            Assert.IsNotNull(nonUsernamePaths);
            Assert.AreEqual(ExpectedNonUsernamePathsCount, nonUsernamePaths.Count);
            Assert.AreEqual(ExpectedNonUsernamePathsFirstItem, nonUsernamePaths.First());
            Assert.AreEqual(ExpectedMaxMediaPerUpload, config.MaxMediaPerUpload);
            Assert.AreEqual(ExpectedShortUrlLengthHttps, config.ShortUrlLengthHttps);
        }