コード例 #1
0
        public void BuildUrl_Returns_Ownerships_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/ownerships.json?user_id=789&screen_name=JoeMayo&count=10&cursor=1";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Ownerships).ToString() },
                { "UserID", "789" },
                { "ScreenName", "JoeMayo" },
                { "Count", "10" },
                { "Cursor", "1" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #2
0
        public void BuildIsSubscriberUrl_Requires_UserID_Or_ScreenName()
        {
            const string ExpectedParamName = "UserIdOrScreenName";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.IsSubscribed).ToString()},
                { "Slug", "test" },
                {"OwnerID", "123"},
            };

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

            Assert.Equal(ExpectedParamName, ex.ParamName);
        }
コード例 #3
0
        public void BuildIsSubscriberUrl_Includes_False_Parameters()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/subscribers/show.json?user_id=789&screen_name=JoeMayo&slug=test&owner_id=123&owner_screen_name=JoeMayo&list_id=456&include_entities=false";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.IsSubscribed).ToString() },
                { "UserID", "789" },
                { "ScreenName", "JoeMayo" },
                { "Slug", "test" },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "ListID", "456" },
                { "IncludeEntities", "false" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #4
0
        public void BuildSubscribersUrl_Requires_Non_Null_And_Not_Empty_ListID_Or_Slug()
        {
            const string ExpectedParamName = "ListIdOrSlug";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Subscribers).ToString()},
                { "ListID", "" },
                { "Slug", null }
                //{"OwnerID", "123"},
            };

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

            Assert.Equal(ExpectedParamName, ex.ParamName);
        }
コード例 #5
0
        public void BuildUrl_Returns_SubscribersUrl()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/subscribers.json?owner_id=123&owner_screen_name=JoeMayo&slug=test&list_id=456&cursor=789&include_entities=true&skip_status=true";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Subscribers).ToString() },
                { "Slug", "test" },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "ListID", "456" },
                { "Cursor", "789" },
                { "IncludeEntities", true.ToString() },
                { "SkipStatus", true.ToString() }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #6
0
        public void BuildShowUrl_Returns_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/show.json?slug=test&owner_id=123&owner_screen_name=JoeMayo&list_id=456";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Show).ToString() },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "Slug", "test" },
                { "ListID", "456" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #7
0
        public void BuildStatusesUrl_Includes_False_Parameters()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/statuses.json?owner_id=123&owner_screen_name=JoeMayo&slug=test&list_id=456&since_id=789&max_id=234&count=25&per_page=25&page=3&trim_user=false&include_entities=false&include_rts=false";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Statuses).ToString() },
                { "OwnerID", "123" },
                { "OwnerScreenName", "JoeMayo" },
                { "Slug", "test" },
                { "ListID", "456" },
                { "SinceID", "789" },
                { "MaxID", "234" },
                { "Count", "25" },
                { "Page", "3" },
                { "TrimUser", "false" },
                { "IncludeEntities", "false" },
                { "IncludeRetweets", "false" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #8
0
        public void BuildListsUrl_Returns_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/list.json?user_id=123&screen_name=JoeMayo&cursor=456&reverse=true";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Lists).ToString() },
                { "UserID", "123" },
                { "ScreenName", "JoeMayo" },
                { "Cursor", "456" },
                { "Reverse", true.ToString() }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #9
0
        public void BuildMembershipsUrl_Does_Not_Add_False_Filter_To_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/memberships.json?user_id=123&screen_name=JoeMayo&cursor=456";
            var listReqProc = new ListRequestProcessor<List>() { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Memberships).ToString() },
                { "UserID", "123" },
                { "ScreenName", "JoeMayo" },
                { "Cursor", "456" },
                { "FilterToOwnedLists", "false" }
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #10
0
        public void BuildUrl_Throws_On_Null_Param_List()
        {
            const string ExpectedParamName = "Type";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };

            var ex = Assert.Throws<ArgumentException>(() => listReqProc.BuildUrl(null));

            Assert.Equal<string>(ExpectedParamName, ex.ParamName);
        }
コード例 #11
0
        public void BuildUrl_Throws_On_Missing_ScreenName()
        {
            const string ExpectedParamName = "UserIdOrScreenName";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", "0" },
                };

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

            Assert.Equal(ExpectedParamName, ex.ParamName);
        }
コード例 #12
0
        public void BuildUrl_Creates_Lists_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/list.json?screen_name=JoeMayo";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)ListType.Lists).ToString() },
                    { "ScreenName", "JoeMayo" }
                };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #13
0
        public void BuildAllListsUrl_Returns_Url_With_UserID()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/lists/all.json?user_id=123";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                {"Type", ((int) ListType.All).ToString(CultureInfo.InvariantCulture)},
                {"UserID", "123"},
            };

            Request req = listReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
コード例 #14
0
        public void BuildStatusesUrl_Requires_OwnerID_Or_OwnerScreenName_If_Slug_Used()
        {
            const string ExpectedParamName = "OwnerIdOrOwnerScreenName";
            var listReqProc = new ListRequestProcessor<List> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>
            {
                { "Type", ((int) ListType.Statuses).ToString()},
                { "Slug", "test" }
                //{"OwnerID", "123"},
            };

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

            Assert.AreEqual(ExpectedParamName, ex.ParamName);
        }