Ejemplo n.º 1
0
        private void AddWrapper()
        {
            Post post = null;

            try
            {
                post = new Post(String.Empty, TweetText, _attachements.ToList());
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            var poster  = new TwitterPoster(_authCreds);
            var wrapper = new TwitterPostWrapper(post, TimeSpan.FromMilliseconds(1), _authCreds);


            wrapper.TryPost();//starts timer
            wrapper.PostingFinished += (sender, e) =>
            {
                if (e.Result) //posting was successfull
                {
                    MessageBox.Show("Tweet posted");
                }
                else
                {
                    MessageBox.Show(e.Exception.Message);//TODO:implement logging
                }
            };
        }
        public void TryingToPostWithValidCredentials_ReturnsTrue()
        {
            var pw = new TwitterPostWrapper("header", "text", new List <Attachement>(),
                                            new TestPoster(), TimeSpan.Zero,
                                            new TwitterAuthCredentials(new TwitterPinObtainer(), new TwitterAppCredentialsObtainer()));

            pw.PostingFinished += (sender, e) => Assert.AreEqual(true, e.Result);
        }