Example #1
0
 /// <summary>
 /// Tweet fav
 /// </summary>
 /// <param name="tweet"></param>
 internal bool CreateFavourite(Twitter.Status tweet)
 {
     try
     {
         _twitterContext.CreateFavorite(tweet.StatusID);
         return(true);
     }
     catch (Exception exception)
     {
         RaiseOperationError(exception);
         return(false);
     }
 }
Example #2
0
        /// <summary>
        /// Shows how to create a Favorite
        /// </summary>
        /// <param name="twitterCtx"></param>
        private static void CreateFavoriteDemo(TwitterContext twitterCtx)
        {
            var status = twitterCtx.CreateFavorite("265675496581373952");

            Console.WriteLine("User: {0}, Tweet: {1}", status.User.Name, status.Text);
        }
        public void CreateFavoriteTest()
        {
            const string Id = "1";
            const string ExpectedStatusID = "184835136037191681";
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostToTwitter(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<Func<string, Status>>()))
                .Returns(SingleStatusResponse);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");

            Status actual = ctx.CreateFavorite(Id);

            Assert.Equal(ExpectedStatusID, actual.StatusID);
        }
        public void CreateFavoriteNoIDTest()
        {
            var authMock = new Mock<ITwitterAuthorizer>();
            var execMock = new Mock<ITwitterExecute>();
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostToTwitter(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<Func<string, Status>>()))
                .Returns(SingleStatusResponse);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "", "");

            var ex = Assert.Throws<ArgumentException>(() => ctx.CreateFavorite(null));

            Assert.Equal("id", ex.ParamName);
        }
 internal static void Favorite(TweetItem selectedItem)
 {
     if (_sampleDataSource._auth == null)
     {
         _sampleDataSource.InitGroups();
     }
     using (var twitterCtx = new TwitterContext(_sampleDataSource._auth))
     {
         Status response = twitterCtx.CreateFavorite(selectedItem.UniqueId);
     }
 }
Example #6
0
        /// <summary>
        /// Shows how to create a Favorite
        /// </summary>
        /// <param name="twitterCtx"></param>
        private static void CreateFavoriteDemo(TwitterContext twitterCtx)
        {
            var status = twitterCtx.CreateFavorite("1552797863");

            Console.WriteLine("User: {0}, Tweet: {1}", status.User.Name, status.Text);
        }