Пример #1
0
        public void BuildUrl_Throws_On_Null_Parameters()
        {
            FriendshipRequestProcessor <Friendship> friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters = null;

            var ex = Assert.Throws <ArgumentException>(() => friendReqProc.BuildUrl(parameters));

            Assert.Equal("Type", ex.ParamName);
        }
Пример #2
0
        public void BuildUrl_Throws_When_Missing_Type()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string> {
            };

            var ex = L2TAssert.Throws <ArgumentException>(() => friendReqProc.BuildUrl(parameters));

            Assert.AreEqual("Type", ex.ParamName);
        }
Пример #3
0
        public void BuildUrl_Throws_Without_FriendsReqProcUrl()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Show.ToString() },
                { "SourceUserID", "123" },
                { "SourceScreenName", "JoeMayo" },
            };

            Assert.Throws <ArgumentException>(() => friendReqProc.BuildUrl(parameters));
        }
Пример #4
0
        public void BuildUrl_Constructs_Outgoing_Url()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Outgoing.ToString() }
            };
            string expected = "https://api.twitter.com/1.1/friendships/outgoing.json";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(expected, req.FullUrl);
        }
Пример #5
0
        public void BuildLookupUrl_Requires_ScreenName_Or_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Lookup.ToString() },
                //{ "ScreenName", "twitter,joemayo" }
            };

            var ex = L2TAssert.Throws <ArgumentNullException>(() => friendReqProc.BuildUrl(parameters));

            Assert.AreEqual("ScreenNameOrUserID", ex.ParamName);
        }
Пример #6
0
        public void BuildUrl_Throws_Without_Source_Url()
        {
            FriendshipRequestProcessor <Friendship> friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", FriendshipType.Show.ToString() },
                { "friendReqProcUserID", "456" },
                { "friendReqProcScreenName", "LinqToTweeter" }
            };

            Assert.Throws <ArgumentException>(() => friendReqProc.BuildUrl(parameters));
        }
Пример #7
0
        public void BuildUrl_Creates_No_Retweet_Url()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "http://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.NoRetweetIDs.ToString() }
            };
            string expected = "http://api.twitter.com/1.1/friendships/no_retweets/ids.json";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(expected, req.FullUrl);
        }
Пример #8
0
        public void BuildUrl_With_Cursor_Param_Constructs_Incoming_Url()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Incoming.ToString() },
                { "Cursor", "-1" }
            };
            string expected = "https://api.twitter.com/1.1/friendships/incoming.json?cursor=-1";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(expected, req.FullUrl);
        }
Пример #9
0
        public void BuildLookupUrl_Returns_Url_For_ScreenName()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Lookup.ToString() },
                { "ScreenName", "twitter,joemayo" }
            };
            string expected = "https://api.twitter.com/1.1/friendships/lookup.json?screen_name=twitter%2Cjoemayo";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(expected, req.FullUrl);
        }
Пример #10
0
        public void BuildLookupUrl_Returns_Url_For_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.Lookup.ToString() },
                { "UserID", "123,456" }
            };
            string expected = "https://api.twitter.com/1.1/friendships/lookup.json?user_id=123%2C456";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(expected, req.FullUrl);
        }
Пример #11
0
        public void BuildFollowerListUrl_Requires_ScreenName_Or_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", FriendshipType.FriendsList.ToString() },
                //{ "UserID", "1" },
                //{ "ScreenName", "abc" }
            };

            var ex = Assert.Throws <ArgumentNullException>(() => friendReqProc.BuildUrl(parameters));

            Assert.Equal("ScreenNameOrUserID", ex.ParamName);
        }
Пример #12
0
        public void BuildUrl_Defaults_Cursor_When_Not_Specified()
        {
            const string ExpectedUrl   = "https://api.twitter.com/1.1/friends/ids.json?screen_name=JoeMayo&cursor=-1";
            var          friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)FriendshipType.FriendIDs).ToString() },
                { "ScreenName", "JoeMayo" },
            };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(ExpectedUrl, req.FullUrl);
        }
Пример #13
0
        public void BuildUrl_Constructs_FriendIDs_Url()
        {
            const string ExpectedUrl   = "https://api.twitter.com/1.1/friends/ids.json?user_id=123&screen_name=456&cursor=1&count=1";
            var          friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", ((int)FriendshipType.FriendIDs).ToString() },
                { "UserID", "123" },
                { "ScreenName", "456" },
                { "Cursor", "1" },
                { "Count", "1" }
            };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(ExpectedUrl, req.FullUrl);
        }
Пример #14
0
        public void BuildUrl_Constructs_Show_Url()
        {
            FriendshipRequestProcessor <Friendship> friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", FriendshipType.Show.ToString() },
                { "SourceUserID", "123" },
                { "SourceScreenName", "JoeMayo" },
                { "TargetUserID", "456" },
                { "TargetScreenName", "LinqToTweeter" }
            };
            string expected = "https://api.twitter.com/1/friendships/show.json?source_id=123&source_screen_name=JoeMayo&target_id=456&target_screen_name=LinqToTweeter";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
Пример #15
0
        public void BuildUrl_Constructs_FollowersList_Url()
        {
            const string ExpectedUrl   = "https://api.twitter.com/1.1/followers/list.json?user_id=1&screen_name=abc&count=20&cursor=def&skip_status=true&include_user_entities=false";
            var          friendReqProc = new FriendshipRequestProcessor <Friendship>()
            {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>
            {
                { "Type", FriendshipType.FollowersList.ToString() },
                { "UserID", "1" },
                { "ScreenName", "abc" },
                { "Count", "20" },
                { "Cursor", "def" },
                { "SkipStatus", true.ToString() },
                { "IncludeUserEntities", false.ToString() }
            };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
        public void BuildUrl_Constructs_Show_Url()
        {
            FriendshipRequestProcessor<Friendship> friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Show.ToString() },
                    { "SourceUserID", "123" },
                    { "SourceScreenName", "JoeMayo" },
                    { "TargetUserID", "456" },
                    { "TargetScreenName", "LinqToTweeter" }
                };
            string expected = "https://api.twitter.com/1/friendships/show.json?source_id=123&source_screen_name=JoeMayo&target_id=456&target_screen_name=LinqToTweeter";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
        public void BuildUrl_Throws_Without_Source_Url()
        {
            FriendshipRequestProcessor<Friendship> friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Show.ToString() },
                    { "friendReqProcUserID", "456" },
                    { "friendReqProcScreenName", "LinqToTweeter" }
                };

            Assert.Throws<ArgumentException>(() => friendReqProc.BuildUrl(parameters));
        }
        public void BuildLookupUrl_Returns_Url_For_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Lookup.ToString() },
                    { "UserID", "123,456" }
                };
            string expected = "https://api.twitter.com/1/friendships/lookup.json?user_id=123%2C456";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
        public void BuildUrl_Throws_On_Null_Parameters()
        {
            FriendshipRequestProcessor<Friendship> friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters = null;

            var ex = Assert.Throws<ArgumentException>(() => friendReqProc.BuildUrl(parameters));

            Assert.Equal("Type", ex.ParamName);
        }
        public void BuildUrl_With_Cursor_Param_Constructs_Outgoing_Url()
        {
            FriendshipRequestProcessor<Friendship> friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Outgoing.ToString() },
                    { "Cursor", "-1" }
                };
            string expected = "https://api.twitter.com/1/friendships/outgoing.json?cursor=-1";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
        public void BuildUrl_Constructs_Incoming_Url()
        {
            FriendshipRequestProcessor<Friendship> friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Incoming.ToString() }
                };
            string expected = "https://api.twitter.com/1/friendships/incoming.json";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
        public void BuildLookupUrl_Requires_ScreenName_Or_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", FriendshipType.Lookup.ToString() },
                //{ "ScreenName", "twitter,joemayo" }
            };

            var ex = L2TAssert.Throws<ArgumentNullException>(() => friendReqProc.BuildUrl(parameters));

            Assert.AreEqual("ScreenNameOrUserID", ex.ParamName);
        }
        public void BuildFollowerListUrl_Requires_ScreenName_Or_UserID()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.FriendsList.ToString() },
                    //{ "UserID", "1" },
                    //{ "ScreenName", "abc" }
                };

            var ex = Assert.Throws<ArgumentNullException>(() => friendReqProc.BuildUrl(parameters));

            Assert.Equal("ScreenNameOrUserID", ex.ParamName);
        }
        public void BuildUrl_Constructs_FollowersList_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/followers/list.json?user_id=1&screen_name=abc&count=20&cursor=def&skip_status=true&include_user_entities=false";
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", FriendshipType.FollowersList.ToString() },
                { "UserID", "1" },
                { "ScreenName", "abc" },
                { "Count", "20" },
                { "Cursor", "def" },
                { "SkipStatus", true.ToString() },
                { "IncludeUserEntities", false.ToString() }
            };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
        public void BuildUrl_Defaults_Cursor_When_Not_Specified()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/friends/ids.json?screen_name=JoeMayo&cursor=-1";
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                    {
                        { "Type", ((int)FriendshipType.FriendIDs).ToString() },
                        { "ScreenName", "JoeMayo" },
                    };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(ExpectedUrl, req.FullUrl);
        }
        public void BuildUrl_Creates_No_Retweet_Url()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "http://api.twitter.com/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.NoRetweetIDs.ToString() }
                };
            string expected = "http://api.twitter.com/friendships/no_retweet_ids.json";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }
        public void BuildUrl_Constructs_FriendIDs_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/friends/ids.json?user_id=123&screen_name=456&cursor=1&count=1";
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
                    {
                        { "Type", ((int)FriendshipType.FriendIDs).ToString() },
                        { "UserID", "123" },
                        { "ScreenName", "456" },
                        { "Cursor", "1" },
                        { "Count", "1" }
                    };

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.AreEqual(ExpectedUrl, req.FullUrl);
        }
        public void BuildUrl_Throws_Without_FriendsReqProcUrl()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", FriendshipType.Show.ToString() },
                { "SourceUserID", "123" },
                { "SourceScreenName", "JoeMayo" },
            };

            Assert.Throws<ArgumentException>(() => friendReqProc.BuildUrl(parameters));
        }
        public void BuildUrl_Throws_When_Missing_Type()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string> { };

            var ex = L2TAssert.Throws<ArgumentException>(() => friendReqProc.BuildUrl(parameters));

            Assert.AreEqual("Type", ex.ParamName);
        }
        public void BuildLookupUrl_Returns_Url_For_ScreenName()
        {
            var friendReqProc = new FriendshipRequestProcessor<Friendship>() { BaseUrl = "https://api.twitter.com/1/" };
            Dictionary<string, string> parameters =
                new Dictionary<string, string>
                {
                    { "Type", FriendshipType.Lookup.ToString() },
                    { "ScreenName", "twitter,joemayo" }
                };
            string expected = "https://api.twitter.com/1/friendships/lookup.json?screen_name=twitter%2Cjoemayo";

            Request req = friendReqProc.BuildUrl(parameters);

            Assert.Equal(expected, req.FullUrl);
        }