Exemple #1
0
        public void TwitterUtility_GetUserID()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            long id = XMLUtility.GetUserId(t.Xml);

            Assert.IsNotNull(id);
        }
Exemple #2
0
        public void TwitterUtility_GetNextRunInterval()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            DateTime nextRun = XMLUtility.GetNextRunInterval(t.Xml);

            Assert.IsNotNull(nextRun);
        }
Exemple #3
0
        public void PostTwitterMentionsToRest()
        {
            string result = string.Empty;

            //http://localhost/BIDataAPI/api/twitter/mentions
            requestPost                       = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/twitter/mentions");
            requestPost.Method                = "POST";
            requestPost.ContentType           = "application/json";
            requestPost.UseDefaultCredentials = true;

            TweetManager  tm = new TweetManager();
            KeywordStatus ks = new KeywordStatus();

            Twitter.Components.Twitter t = new Twitter.Components.Twitter();
            ks.KeywordId  = 7;
            ks.StatusList = tm.GetTweetsByQuery(20, Uri.EscapeDataString("\"go daddy\" OR godaddy OR go-daddy"), Twitter.Utility.GetOAuthToken(t.Xml));

            string requestData = new JavaScriptSerializer().Serialize(ks);

            byte[] data = Encoding.UTF8.GetBytes(requestData);

            using (Stream dataStream = requestPost.GetRequestStream())
                dataStream.Write(data, 0, data.Length);

            HttpWebResponse response = requestPost.GetResponse() as HttpWebResponse;

            result = new StreamReader(response.GetResponseStream()).ReadToEnd();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
        }
Exemple #4
0
        public void PostTwitterUsersToRest()
        {
            string result = string.Empty;

            requestPost                       = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/twitter/users");
            requestPost.Method                = "POST";
            requestPost.ContentType           = "application/json";
            requestPost.UseDefaultCredentials = true;

            List <User>           _twitterUserList = new List <User>();
            TwitterUserDataSource dataSource       = new TwitterUserDataSource();
            UserManager           um = new UserManager();

            Twitter.Components.Twitter t = new Twitter.Components.Twitter();

            foreach (Competitor comp in dataSource.GetCompetitorAccounts())
            {
                _twitterUserList.Add(um.GetTwitterUserInfo(comp.TwitterID, Twitter.Utility.GetOAuthToken(t.Xml)));
            }

            string requestData = new JavaScriptSerializer().Serialize(_twitterUserList);

            byte[] data = Encoding.UTF8.GetBytes(requestData);

            using (Stream dataStream = requestPost.GetRequestStream())
                dataStream.Write(data, 0, data.Length);

            HttpWebResponse response = requestPost.GetResponse() as HttpWebResponse;

            result = new StreamReader(response.GetResponseStream()).ReadToEnd();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
        }
Exemple #5
0
        public void TwitterUtility_IsComponentEnabled()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.IsComponentEnabled(t.Xml, "twittertrend");

            Assert.IsFalse(enabledProperty);
        }
Exemple #6
0
        public void TwitterUtility_IsEnabled_BadXmlDefaultsFalse()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.IsEnabled(new XmlDocument());

            Assert.IsFalse(enabledProperty);
        }
Exemple #7
0
        public void TwitterUtility_UseSinceID()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.UseSinceId(t.Xml, "twitter");

            Assert.IsTrue(enabledProperty);
        }
Exemple #8
0
        public void TwitterUtility_IsEnabled()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.IsEnabled(t.Xml);

            Assert.IsTrue(enabledProperty);
        }
Exemple #9
0
        public void TwitterUtility_GetNext15MinRunTime()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            DateTime nextRun = XMLUtility.GetNext15MinRunTime();

            Assert.IsNotNull(nextRun);
            Assert.IsTrue(nextRun.Minute % 15 == 0);
        }
Exemple #10
0
        public void TwitterUser_GetALlFollowers()
        {
            Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            OAuthTokens oat = Drone.Twitter.Utility.GetOAuthToken(t.Xml);

            UserManager um = new UserManager();

            um.GetAllFollowers(oat);
        }
Exemple #11
0
        public void Twitter_GetData()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterDataSource());
            t.GetData(t.Context);
            TwitterDataComponent tdc = t.DroneDataComponent as TwitterDataComponent;

            Assert.AreEqual(Drone.Twitter.Components.Twitter.ComponentTypeName, "TwitterComponent");
            //Assert.IsNotNull(tdc.AllTwitterMentions);
        }
Exemple #12
0
        public void TwitterUtility_GetOAuthToken()
        {
            Drone.Twitter.Components.Twitter    t   = new Twitter.Components.Twitter(new TwitterTestDataSource());
            Drone.API.Twitter.OAuth.OAuthTokens oat = Drone.Twitter.Utility.GetOAuthToken(t.Xml);

            Assert.IsNotNull(oat);
            Assert.IsTrue(oat.HasAccessToken);
            Assert.IsTrue(oat.HasConsumerToken);
        }
Exemple #13
0
        public void TwitterUtility_GetPageResultCounts_DefaultsCorrectly()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            int countPerPage; int pageCount;

            XMLUtility.GetPageResultCounts(new XmlDocument(), "twitter", out countPerPage, out pageCount, 100, 3);

            Assert.AreEqual(countPerPage, 100);
            Assert.AreEqual(pageCount, 3);
        }
Exemple #14
0
        public void TwitterUtility_GetPageResultCounts()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            int countPerPage; int pageCount;

            XMLUtility.GetPageResultCounts(t.Xml, "twitter", out countPerPage, out pageCount, 100, 3);

            Assert.AreEqual(countPerPage, 100);
            Assert.AreEqual(pageCount, 5);
        }
Exemple #15
0
        public void TwitterUser_GetFollowerCountsFromCSV()
        {
            Utility.ComponentBaseFolder = AppDomain.CurrentDomain.BaseDirectory;

            Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            OAuthTokens oat = Drone.Twitter.Utility.GetOAuthToken(t.Xml);

            UserManager um = new UserManager();

            um.GetFollowerCounts(oat);
        }
Exemple #16
0
        public void Twitter_GetAvailablePlaces()
        {
            Drone.Twitter.Components.Twitter t   = new Twitter.Components.Twitter(new TwitterTestDataSource());
            TwitterDataComponent             tdc = t.DroneDataComponent as TwitterDataComponent;

            tdc.TwitterAvailablePlaces = Drone.Twitter.Components.Twitter.GetAvailablePlaces();

            foreach (var item in tdc.TwitterAvailablePlaces.OrderBy(x => x.country))
            {
                Debug.WriteLine(string.Format("Country:{0}.  Name:{1}.  WoeID:{3}  Type:{2}", item.country, item.name, item.placeType.name, item.woeid));
            }

            Assert.IsNotNull(tdc.TwitterAvailablePlaces);
        }
Exemple #17
0
 public void Twitter_GetData_RateLimitTest()
 {
     Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
     while (true)
     {
         try
         {
             t.GetData(t.Context);
         }
         catch (System.Exception)
         { }
         Thread.Sleep(60000);                 //one minute seems to be the fastest w/out hitting rate limits
     }
 }