Exemple #1
0
        protected override void OnStart(string[] args)
        {
            // Arrange
            var controller = new TwitterController();

            var token = controller.GetAuthToken(OAuthConsumerKey, OAuthConsumerSecret);

            var applicationTweets = controller.GetApplicationTweets(token, HashTag);

            string lastId = "0";

            using (var sr = new StreamReader(FileName))
            {
                lastId = sr.ReadLine();
            }

            foreach (var applicationTweet in applicationTweets)
            {
                var tweet = new SendTweetOptions
                {
                    Status            = String.Format("@{0} Thanks for applying! You'll receive a confirmation email shortly.", applicationTweet.in_reply_to_screen_name),
                    InReplyToStatusId = Int64.Parse(applicationTweet.id_str),
                };

                var actual = controller.PostTweet(token, tweet);

                lastId = applicationTweet.id_str;
            }

            using (var sw = new StreamWriter(FileName, false, Encoding.ASCII))
            {
                sw.WriteLine(lastId);
            }
        }
Exemple #2
0
        public void PostTweet_ShouldOnlyReplyOnce_Succeeds()
        {
            // Arrange
            var controller = new TwitterController();

            var token = controller.GetAuthToken(OAuthConsumerKey, OAuthConsumerSecret);

            var applicationTweets = controller.GetApplicationTweets(token, HashTag);

            string lastId = "0";

            foreach (var applicationTweet in applicationTweets)
            {
                var tweet = new SendTweetOptions
                {
                    Status            = String.Format("@{0} Thanks for applying! You'll receive a confirmation email shortly.", applicationTweet.in_reply_to_screen_name),
                    InReplyToStatusId = Int64.Parse(applicationTweet.id_str),
                };

                var actual = controller.PostTweet(token, tweet);

                lastId = applicationTweet.id_str;

                Assert.IsNotNull(actual);
            }

            applicationTweets = controller.GetApplicationTweets(token, HashTag, lastId);
            Assert.IsTrue(!applicationTweets.Any());
        }
Exemple #3
0
        public void PostTweet_WithValidCredentials_Succeeds()
        {
            // Arrange
            var controller = new TwitterController();

            var token = controller.GetAuthToken(OAuthConsumerKey, OAuthConsumerSecret);

            var tweet = new SendTweetOptions
            {
                Status = "Hacking #HackApply-" + DateTime.Now.Millisecond
            };

            var actual = controller.PostTweet(token, tweet);

            Assert.IsNotNull(actual);
        }
Exemple #4
0
        public void PostTweet_InReplyOfApplicationTweet_Succeeds()
        {
            // Arrange
            var controller = new TwitterController();

            var token = controller.GetAuthToken(OAuthConsumerKey, OAuthConsumerSecret);

            var applicationTweets = controller.GetApplicationTweets(token, HashTag);

            foreach (var applicationTweet in applicationTweets)
            {
                var guid  = DateTime.Now.ToLongTimeString();
                var tweet = new SendTweetOptions
                {
                    Status            = String.Format("@{0} Thanks for applying! You'll receive a confirmation email shortly.{1}", applicationTweet.in_reply_to_screen_name, guid),
                    InReplyToStatusId = Int64.Parse(applicationTweet.id_str),
                };

                var actual = controller.PostTweet(token, tweet);
                Assert.IsNotNull(actual);
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            var controller = new TwitterController();

            var token = controller.GetAuthToken(OAuthConsumerKey, OAuthConsumerSecret);

            string lastId = "0";

            using (var sr = new StreamReader(FileName))
            {
                lastId = sr.ReadLine();
            }

            var applicationTweets = controller.GetApplicationTweets(token, HashTag, "0");

            foreach (var applicationTweet in applicationTweets)
            {
                var environmentSuffix = "dev";
                //var environmentSuffix = "web-navy-int1";
                var jobseekerBaseUrl = String.Format("http://www.seek.com.au.{0}", environmentSuffix);
                var jobUrl           = applicationTweet.jobUrl;

                string twitterHandle = applicationTweet.user.screen_name.ToString();

                var loginIds = GetLoginIdsForTwitterHandle(jobseekerBaseUrl, twitterHandle).ToList();

                var tweet = new SendTweetOptions();
                var guid  = DateTime.Now.ToLongTimeString();

                if (loginIds.Count() == 1)
                {
                    tweet = new SendTweetOptions
                    {
                        Status            = String.Format("@{0} Thanks for applying! You'll receive a confirmation email shortly.{1}", twitterHandle, guid),
                        InReplyToStatusId = Int64.Parse(applicationTweet.id_str),
                    };

                    // Post an application
                    var statusCode = ApplyByTwitter(jobseekerBaseUrl, jobUrl, loginIds[0]);

                    // Check the status code for success or failure
                }
                else
                {
                    tweet = new SendTweetOptions
                    {
                        Status            = String.Format("Thanks @{0}! To complete your application sign in and update your twitter details here https://www.seek.com.au.web-navy-int1/Register/Standalone - {1}", twitterHandle, guid),
                        InReplyToStatusId = Int64.Parse(applicationTweet.id_str),
                    };
                }

                var actual = controller.PostTweet(token, tweet);

                lastId = applicationTweet.id_str;
            }

            using (var sw = new StreamWriter(FileName, false, Encoding.ASCII))
            {
                sw.WriteLine(lastId);
            }
        }