Beispiel #1
0
        /// <summary>
        /// Shows how to update the background image in an account
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateAccountBackgroundImageBytes(TwitterContext twitterCtx)
        {
            byte[] fileBytes = Utilities.GetFileBytes(@"C:\Users\jmayo\Documents\linq2twitter\linq2twitter\200xColor_2.png");
            var user = twitterCtx.UpdateAccountBackgroundImage(fileBytes, "200xColor_2.png", "png", false);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #2
0
        /// <summary>
        /// Shows how to update the background image in an account and tiles the image
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        static void UpdateAccountBackgroundImageAndTileDemo(TwitterContext twitterCtx)
        {
            byte[] fileBytes = Utilities.GetFileBytes(@"..\..\images\200xColor_2.png");
            var user = twitterCtx.UpdateAccountBackgroundImage(fileBytes, "200xColor_2.png", "png", true, true, true, true);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #3
0
        /// <summary>
        /// Shows how to update the background image in an account and tiles the image
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateAccountBackgroundImageAndTileDemo(TwitterContext twitterCtx)
        {
            byte[] fileBytes = Utilities.GetFileBytes(@"C:\Users\jmayo\Documents\linq2twitter\linq2twitter\linq2twitter_v3_300x90.png");
            var user = twitterCtx.UpdateAccountBackgroundImage(fileBytes, "linq2twitter_v3_300x90.png", "png", true);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #4
0
        /// <summary>
        /// hows how to use OAuth to post a file to Twitter
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void HandleOAuthFilePostDemo(TwitterContext twitterCtx)
        {
            if (twitterCtx.AuthorizedClient.IsAuthorized)
            {
                var user = twitterCtx.UpdateAccountBackgroundImage(
                    @"C:\Users\jmayo\Documents\linq2twitter\linq2twitter\200xColor_2.png", false);

                Console.WriteLine(
                    "Name: {0}\nImage: {1}\n",
                    user.Name,
                    user.ProfileBackgroundImageUrl);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Shows how to update the background image in an account
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        static void UpdateAccountBackgroundImage(TwitterContext twitterCtx)
        {
            var user = twitterCtx.UpdateAccountBackgroundImage(@"..\..\images\200xColor_2.png", false, true, true, true);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #6
0
        /// <summary>
        /// Shows how to update the background image in an account
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        static void UpdateAccountBackgroundImageWithProgressUpdates(TwitterContext twitterCtx)
        {
            twitterCtx.UploadProgressChanged +=
                (sender, e) =>
                {
                    Console.WriteLine("Progress: {0}%", e.PercentComplete);
                };
            byte[] fileBytes = Utilities.GetFileBytes(@"..\..\images\200xColor_2.png");
            var user = twitterCtx.UpdateAccountBackgroundImage(fileBytes, "200xColor_2.png", "png", false, true, true, true);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #7
0
        /// <summary>
        /// Shows how to update the background image in an account
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void UpdateAccountBackgroundImage(TwitterContext twitterCtx)
        {
            var user = twitterCtx.UpdateAccountBackgroundImage(@"C:\Users\jmayo\Documents\linq2twitter\linq2twitter\linq2twitter_v3_300x90.png", false);

            Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
        }
Beispiel #8
0
        /// <summary>
        /// Shows how to update the background image with OAuth
        /// </summary>
        /// <param name="twitterCtx">TwitterContext</param>
        private static void HandleOAuthUpdateAccountBackgroundImageWithProgressUpdatesDemo(TwitterContext twitterCtx)
        {
            if (twitterCtx.AuthorizedClient.IsAuthorized)
            {
                twitterCtx.UploadProgressChanged +=
                        (sender, e) =>
                        {
                            Console.WriteLine("Progress: {0}%", e.PercentComplete);
                        };
                byte[] fileBytes = Utilities.GetFileBytes(@"C:\Users\jmayo\Documents\linq2twitter\linq2twitter\200xColor_2.png");
                var user = twitterCtx.UpdateAccountBackgroundImage(fileBytes, "200xColor_2.png", "png", true, true, true, true);

                Console.WriteLine("User Image: " + user.ProfileBackgroundImageUrl);
            }
        }
        public void UpdateAccountBackgroundImage_Invokes_Executor_PostTwitterFile()
        {
            const string ImageFilePath = "C:\\image.png";
            const bool Tile = false;
            const bool Use = false;
            const string ExpectedName = "Twitter API";
            const bool SkipStatus = true;
            execMock.SetupGet(exec => exec.AuthorizedClient).Returns(authMock.Object);
            execMock.Setup(exec =>
                exec.PostTwitterFile(
                    It.IsAny<string>(),
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<string>(),
                    It.IsAny<IRequestProcessor<User>>()))
                .Returns(SingleUserResponse);
            var ctx = new TwitterContext(authMock.Object, execMock.Object, "https://api.twitter.com/1.1/", "");

            User actual = ctx.UpdateAccountBackgroundImage(ImageFilePath, Tile, Use, true, SkipStatus);

            execMock.Verify(exec =>
                exec.PostTwitterFile(
                    "https://api.twitter.com/1.1/account/update_profile_background_image.json",
                    It.IsAny<Dictionary<string, string>>(),
                    It.IsAny<string>(),
                    It.IsAny<IRequestProcessor<User>>()),
                Times.Once());
            Assert.Equal(ExpectedName, actual.Name);
        }