예제 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     // For some reason this app throws random error when loading the page first time. I made this dirty fix to wait a little before actually loading the page.
     // It seems to help
     Thread.Sleep(500);
     // Enable RateLimit Tracking. Tracks and waits, so in worst case the app stops working for 15 minutes as tokens are gained in 15 minute intervals
     // Couldn't get TrackOnly method to work
     RateLimit.RateLimitTrackerMode = RateLimitTrackerMode.TrackAndAwait;
     if (!IsPostBack)
     {
         try
         {
             // Redirect to log in page if session user is null
             if (Session["user"] == null)
             {
                 Response.Redirect("LogIn.aspx");
             }
             user = (IAuthenticatedUser)Session["user"];
             InitUserData(user);
             // Gets 200 latest tweets and mentions
             latestTweets = user.GetHomeTimeline(200);
             userMentions = user.GetMentionsTimeline(200);
         }
         catch (Exception ex)
         {
             lblError.Text = ex.Message;
         }
     }
     GenerateTimeline();
 }
예제 #2
0
        private static void FollowerInteraction()
        {
            foreach (IUser user in authenticatedUser.GetFollowers(int.MaxValue))
            {
                if (!user.Following)
                {
                    authenticatedUser.FollowUser(user);
                }
            }

            foreach (IMention mention in authenticatedUser.GetMentionsTimeline(int.MaxValue))
            {
                if (!mention.Favorited)
                {
                    mention.Favorite();
                }
            }
        }
        public void GetMentionsTimeline_CurrentCredentialsAreNotAuthenticatedUserCredentials_OperationPerformedWithAppropriateCredentials()
        {
            // Arrange
            var nbTweets = TestHelper.GenerateRandomInt();

            ITwitterCredentials startOperationWithCredentials = null;

            _fakeTimelineController.CallsTo(x => x.GetMentionsTimeline(nbTweets)).Invokes(() =>
            {
                startOperationWithCredentials = _fakeCredentialsAccessor.FakedObject.CurrentThreadCredentials;
            });

            // Act
            _authenticatedUser.GetMentionsTimeline(nbTweets);

            // Assert
            Assert.AreEqual(startOperationWithCredentials, _authenticatedUserCredentials);
            Assert.AreEqual(_fakeCredentialsAccessor.FakedObject.CurrentThreadCredentials, _currentCredentials);
        }