public void TweetWithMedia_Without_Location_Params_Returns_Status()
        {
            Status tweet = StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            Assert.True(tweet.Text.StartsWith("RT @scottgu: I just blogged about"));
        }
        public void TweetWithMedia_Returns_Status()
        {
            Status tweet = StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            Assert.True(tweet.Text.StartsWith("RT @scottgu: I just blogged about"));
        }
        public void TweetWithMedia_Accepts_Internationalized_Characters()
        {
            string statusMsg = "My new car £10,555. http://test.com #CodePlex #testing";

            Status tweet = StatusExtensions.TweetWithMedia(
                twitterCtx.Object, statusMsg, possiblySensitive, mediaItems);

            Assert.True(tweet.Text.StartsWith("RT @scottgu: I just blogged about"));
        }
        public void TweetWithMedia_Without_Location_Params_Requires_At_Least_One_Media()
        {
            mediaItems = new List <Media>();

            ArgumentException ex =
                Assert.Throws <ArgumentException>(() => StatusExtensions.TweetWithMedia(
                                                      twitterCtx.Object, status, possiblySensitive, mediaItems));

            Assert.Equal("mediaItems", ex.ParamName);
        }
        public void TweetWithMedia_Without_Location_Params_Requires_NonNull_MediaItems()
        {
            mediaItems = null;

            ArgumentNullException ex =
                Assert.Throws <ArgumentNullException>(() => StatusExtensions.TweetWithMedia(
                                                          twitterCtx.Object, status, possiblySensitive, mediaItems));

            Assert.Equal("mediaItems", ex.ParamName);
        }
        public void TweetWithMedia_Sets_Callback()
        {
            twitterExecute.SetupSet(exec => exec.AsyncCallback = It.IsAny <Delegate>());

            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive,
                latitude, longitude, placeID, displayCoordinates,
                mediaItems, null);

            this.twitterExecute.VerifySet(exec => exec.AsyncCallback = It.IsAny <Delegate>());
        }
        public void TweetWithMedia_Without_Location_Params_Passes_Properly_Formatted_Url_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.Is <string>(url => url == expectedUploadUrl),
                                      It.IsAny <IDictionary <string, string> >(),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia didn't pass properly formatted URL.");
        }
        public void TweetWithMedia_Without_Location_Params_Passes_Status_Via_Parameter_Dictionary_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["status"] == status),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia didn't pass status properly.");
        }
        public void TweetWithMedia_Without_Location_Params_DoesNot_Pass_DisplayCoordinates_Via_Parameter_Dictionary_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["display_coordinates"] == null),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia shouldn't pass displayCoordinates parameter.");
        }
        public void TweetWithMedia_Without_Location_Params_Calls_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.IsAny <IDictionary <string, string> >(),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "PostMedia was not called only one time.");
        }
        public void TweetWithMedia_Without_Location_Params_Throws_On_Null_Status()
        {
            this.status = null;

            ArgumentNullException ex =
                Assert.Throws <ArgumentNullException>(() =>
            {
                StatusExtensions.TweetWithMedia(
                    twitterCtx.Object, status, possiblySensitive, mediaItems);
            });

            Assert.Equal("status", ex.ParamName);
        }
        public void TweetWithMedia_Requires_At_Least_One_Media()
        {
            this.mediaItems = new List <Media>();

            ArgumentException ex =
                Assert.Throws <ArgumentException>(() =>
                                                  StatusExtensions.TweetWithMedia(
                                                      this.twitterCtx.Object, this.status, this.possiblySensitive,
                                                      this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                                                      this.mediaItems, null));

            Assert.Equal("mediaItems", ex.ParamName);
        }
        public void TweetWithMedia_Without_Location_Params_Passes_IRequestProcessor_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.IsAny <IDictionary <string, string> >(),
                                      It.IsAny <List <Media> >(),
                                      It.Is <IRequestProcessor <Status> >(reqProc => reqProc != null && reqProc is IRequestProcessor <Status>)),
                                  Times.Once(),
                                  "TweetWithMedia didn't pass reqProc properly.");
        }
        public void TweetWithMedia_Without_Location_Params_Passes_Media_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.IsAny <IDictionary <string, string> >(),
                                      It.Is <List <Media> >(media => object.ReferenceEquals(media, this.mediaItems)),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia didn't pass mediaItems properly.");
        }
        public void TweetWithMedia_Without_Location_Params_DoesNot_Pass_Lat_And_Long_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["lat"] == null && parms["long"] == null),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "Lat and long should be null.");
        }
        public void TweetWithMedia_Without_Location_Params_DoesNot_Pass_InReplyToStatusID_Via_Parameter_Dictionary_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => !parms.ContainsKey("in_reply_To_status_id")),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia shouldn't pass inReplyToStatusID parameter.");
        }
        public void TweetWithMedia_DoesNot_Pass_InReplyToStatusID_Via_Parameter_Dictionary_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["in_reply_to_status_id"] == null),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia shouldn't pass inReplyToStatusID parameter.");
        }
        public void TweetWithMedia_Without_Location_Params_DoesNot_Pass_False_PossiblySensitive_Via_Parameter_Dictionary_To_PostMedia()
        {
            possiblySensitive = false;

            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, status, possiblySensitive, mediaItems);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["possibly_sensitive"] == null),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "TweetWithMedia should not have passed possiblySensitive parameter.");
        }
        public void TweetWithMedia_Throws_On_Null_Status()
        {
            this.status = null;

            ArgumentNullException ex =
                Assert.Throws <ArgumentNullException>(() =>
            {
                StatusExtensions.TweetWithMedia(
                    this.twitterCtx.Object, this.status, this.possiblySensitive,
                    this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                    this.mediaItems, null);
            });

            Assert.Equal("status", ex.ParamName);
        }
        public void TweetWithMedia_Passes_Properly_Formatted_Url_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            this.twitterExecute.Verify(exec =>
                                       exec.PostMedia(
                                           It.Is <string>(url => url == this.expectedUploadUrl),
                                           It.IsAny <IDictionary <string, string> >(),
                                           It.IsAny <List <Media> >(),
                                           It.IsAny <IRequestProcessor <Status> >()),
                                       Times.Once(),
                                       "TweetWithMedia didn't pass properly formatted URL.");
        }
        public void TweetWithMedia_Calls_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            this.twitterExecute.Verify(exec =>
                                       exec.PostMedia(
                                           It.IsAny <string>(),
                                           It.IsAny <IDictionary <string, string> >(),
                                           It.IsAny <List <Media> >(),
                                           It.IsAny <IRequestProcessor <Status> >()),
                                       Times.Once(),
                                       "PostMedia was not called only one time.");
        }
        public void TweetWithMedia_Passes_Longitude_Via_Parameter_Dictionary_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            this.twitterExecute.Verify(exec =>
                                       exec.PostMedia(
                                           It.IsAny <string>(),
                                           It.Is <IDictionary <string, string> >(parms => parms["long"] == longitude.ToString()),
                                           It.IsAny <List <Media> >(),
                                           It.IsAny <IRequestProcessor <Status> >()),
                                       Times.Once(),
                                       "TweetWithMedia didn't pass longitude parameter properly.");
        }
        public void TweetWithMedia_Passes_Media_To_PostMedia()
        {
            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            this.twitterExecute.Verify(exec =>
                                       exec.PostMedia(
                                           It.IsAny <string>(),
                                           It.IsAny <IDictionary <string, string> >(),
                                           It.Is <List <Media> >(media => object.ReferenceEquals(media, this.mediaItems)),
                                           It.IsAny <IRequestProcessor <Status> >()),
                                       Times.Once(),
                                       "TweetWithMedia didn't pass mediaItems properly.");
        }
        public void TweetWithMedia_DoesNot_Pass_NoCoordinate_Lat_And_Long_To_PostMedia()
        {
            this.latitude  = StatusExtensions.NoCoordinate;
            this.longitude = StatusExtensions.NoCoordinate;

            StatusExtensions.TweetWithMedia(
                twitterCtx.Object, this.status, this.possiblySensitive,
                latitude, this.longitude, this.placeID, this.displayCoordinates,
                mediaItems, null);

            twitterExecute.Verify(exec => exec.PostMedia(
                                      It.IsAny <string>(),
                                      It.Is <IDictionary <string, string> >(parms => parms["lat"] == null && parms["long"] == null),
                                      It.IsAny <List <Media> >(),
                                      It.IsAny <IRequestProcessor <Status> >()),
                                  Times.Once(),
                                  "Lat and long should be null.");
        }
        public void TweetWithMedia_Translates_Localized_Lat_And_Long()
        {
            string latString  = this.latitude.ToString();
            string longString = this.longitude.ToString();

            Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.frenchLocale);

            StatusExtensions.TweetWithMedia(
                this.twitterCtx.Object, this.status, this.possiblySensitive,
                this.latitude, this.longitude, this.placeID, this.displayCoordinates,
                this.mediaItems, null);

            this.twitterExecute.Verify(exec =>
                                       exec.PostMedia(
                                           It.IsAny <string>(),
                                           It.Is <IDictionary <string, string> >(
                                               parms =>
                                               parms["lat"] == latString &&
                                               parms["long"] == longString),
                                           It.IsAny <List <Media> >(),
                                           It.IsAny <IRequestProcessor <Status> >()),
                                       Times.Once(),
                                       "Invariant culture not applied to Lat and/or long.");
        }