public void GetParameters_Handles_Input_Params() { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph>(); Expression<Func<SocialGraph, bool>> expression = graph => graph.Type == SocialGraphType.Followers && graph.UserID == 123ul && graph.ScreenName == "456" && graph.Cursor == "-1" && graph.Count == 1; var lambdaExpression = expression as LambdaExpression; var queryParams = graphReqProc.GetParameters(lambdaExpression); Assert.True( queryParams.Contains( new KeyValuePair<string, string>("Type", ((int)SocialGraphType.Followers).ToString()))); Assert.True( queryParams.Contains( new KeyValuePair<string, string>("UserID", "123"))); Assert.True( queryParams.Contains( new KeyValuePair<string, string>("ScreenName", "456"))); Assert.True( queryParams.Contains( new KeyValuePair<string, string>("Cursor", "-1"))); Assert.True( queryParams.Contains( new KeyValuePair<string, string>("Count", "1"))); }
public void GetParametersTest() { SocialGraphRequestProcessor target = new SocialGraphRequestProcessor(); Expression <Func <SocialGraph, bool> > expression = graph => graph.Type == SocialGraphType.Followers && graph.ID == 123 && graph.ScreenName == "456" && graph.Page == 1; LambdaExpression lambdaExpression = expression as LambdaExpression; var queryParams = target.GetParameters(lambdaExpression); Assert.IsTrue( queryParams.Contains( new KeyValuePair <string, string>("Type", ((int)SocialGraphType.Followers).ToString()))); Assert.IsTrue( queryParams.Contains( new KeyValuePair <string, string>("ID", "123"))); Assert.IsTrue( queryParams.Contains( new KeyValuePair <string, string>("ScreenName", "456"))); Assert.IsTrue( queryParams.Contains( new KeyValuePair <string, string>("Page", "1"))); }
public void ProcessResults_Populates_Input_Parameters() { var statProc = new SocialGraphRequestProcessor <SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/", Type = SocialGraphType.Friends, UserID = 123, ScreenName = "abc", Cursor = "-1", Count = 3, }; var graphResult = statProc.ProcessResults(TestQueryResponse); Assert.NotNull(graphResult); Assert.Single(graphResult); var graph = graphResult.Single(); Assert.NotNull(graph); Assert.Equal(SocialGraphType.Friends, graph.Type); Assert.Equal(123ul, graph.UserID); Assert.Equal("abc", graph.ScreenName); Assert.Equal("-1", graph.Cursor); Assert.Equal(3, graph.Count); }
public void ProcessResults_Returns_Empty_Collection_When_Empty_Results() { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph>(); var graph = graphReqProc.ProcessResults(string.Empty); Assert.Empty(graph); }
public void ProcessResultsTest() { SocialGraphRequestProcessor target = new SocialGraphRequestProcessor(); XElement twitterResponse = XElement.Parse(m_testQueryResponse); IList actual = target.ProcessResults(twitterResponse); var graph = actual.Cast <SocialGraph>().ToList(); Assert.AreEqual(graph[0].ID, 123456); Assert.AreEqual(graph[1].ID, 987654); }
public void BuildUrl_Throws_On_Null_Params() { var graphReqProc = new SocialGraphRequestProcessor <SocialGraph> { BaseUrl = "https://api.twitter.com/1.1/" }; var ex = Assert.Throws <ArgumentException>(() => graphReqProc.BuildUrl(null)); Assert.Equal <string>("Type", ex.ParamName); }
public void BuildUrl_Throws_On_Missing_Type() { var graphReqProc = new SocialGraphRequestProcessor <SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/" }; var parameters = new Dictionary <string, string>(); var ex = Assert.Throws <ArgumentException>(() => graphReqProc.BuildUrl(parameters)); Assert.Equal("Type", ex.ParamName); }
public void BuildURLTest() { SocialGraphRequestProcessor target = new SocialGraphRequestProcessor() { BaseUrl = "http://twitter.com/" }; Dictionary <string, string> parameters = new Dictionary <string, string>(); string expected = "http://twitter.com/friends/ids.xml"; string actual; actual = target.BuildURL(parameters); Assert.AreEqual(expected, actual); }
public void BuildUrl_Defaults_Cursor_When_Not_Specified() { const string ExpectedUrl = "https://api.twitter.com/1/friends/ids.json?screen_name=JoeMayo&cursor=-1"; var socialGraph = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "https://api.twitter.com/1/" }; Dictionary<string, string> parameters = new Dictionary<string, string> { { "Type", SocialGraphType.Friends.ToString() }, { "ScreenName", "JoeMayo" }, }; Request req = socialGraph.BuildUrl(parameters); Assert.Equal(ExpectedUrl, req.FullUrl); }
public void BuildUrl_Constructs_Friends_Url() { const string ExpectedUrl = "https://api.twitter.com/1/friends/ids.json?user_id=123&screen_name=456&cursor=1"; var graphReqProc = new SocialGraphRequestProcessor<SocialGraph> { BaseUrl = "https://api.twitter.com/1/" }; var parameters = new Dictionary<string, string> { { "Type", "0" }, { "UserID", "123" }, { "ScreenName", "456" }, { "Cursor", "1" } }; Request req = graphReqProc.BuildUrl(parameters); Assert.Equal(ExpectedUrl, req.FullUrl); }
public void BuildSocialGraphFriendsUrlTest() { SocialGraphRequestProcessor<SocialGraph> target = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "http://twitter.com/" }; Dictionary<string, string> parameters = new Dictionary<string, string> { { "Type", "0" }, { "ID", "JoeMayo" }, { "UserID", "123" }, { "ScreenName", "456" }, { "Page", "1" } }; string expected = "http://twitter.com/friends/ids/JoeMayo.xml?user_id=123&screen_name=456&page=1"; string actual; actual = target.BuildURL(parameters); Assert.AreEqual(expected, actual); }
void TestQueryResponseParsesCorrectly(SocialGraphType type) { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph> { Type = type }; List<SocialGraph> graphResponse = graphReqProc.ProcessResults(TestQueryResponse); Assert.NotNull(graphResponse); Assert.Single(graphResponse); var graph = graphResponse.First(); var ids = graph.IDs; Assert.NotNull(ids); Assert.Equal(ids[0], "547559234"); Assert.Equal(ids[1], "189123075"); var cursor = graph.CursorMovement; Assert.NotNull(cursor); Assert.Equal("2", cursor.Previous); Assert.Equal("3", cursor.Next); }
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 socialGraph = new SocialGraphRequestProcessor <SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/" }; Dictionary <string, string> parameters = new Dictionary <string, string> { { "Type", SocialGraphType.Friends.ToString() }, { "ScreenName", "JoeMayo" }, }; Request req = socialGraph.BuildUrl(parameters); Assert.Equal(ExpectedUrl, req.FullUrl); }
public void NullParametersTest() { SocialGraphRequestProcessor <SocialGraph> target = new SocialGraphRequestProcessor <SocialGraph>() { BaseUrl = "http://twitter.com/" }; Dictionary <string, string> parameters = null; string actual; try { actual = target.BuildURL(parameters); Assert.Fail("Expected ArgumentException."); } catch (ArgumentException ae) { Assert.AreEqual <string>("Type", ae.ParamName); } }
public void BuildUrl_Constructs_Friends_Url() { const string ExpectedUrl = "https://api.twitter.com/1.1/friends/ids.json?user_id=123&screen_name=456&cursor=1&count=1"; var graphReqProc = new SocialGraphRequestProcessor <SocialGraph> { BaseUrl = "https://api.twitter.com/1.1/" }; var parameters = new Dictionary <string, string> { { "Type", "0" }, { "UserID", "123" }, { "ScreenName", "456" }, { "Cursor", "1" }, { "Count", "1" } }; Request req = graphReqProc.BuildUrl(parameters); Assert.Equal(ExpectedUrl, req.FullUrl); }
public void BuildSocialGraphFollowersUrlTest() { SocialGraphRequestProcessor target = new SocialGraphRequestProcessor() { BaseUrl = "http://twitter.com/" }; Dictionary <string, string> parameters = new Dictionary <string, string> { { "Type", "1" }, { "ID", "JoeMayo" }, { "UserID", "123" }, { "ScreenName", "456" }, { "Page", "1" } }; string expected = "http://twitter.com/followers/ids/JoeMayo.xml?user_id=123&screen_name=456&page=1"; string actual; actual = target.BuildURL(parameters); Assert.AreEqual(expected, actual); }
public void BuildUrl_Constructs_Followers_Url() { const string ExpectedUrl = "https://api.twitter.com/1.1/followers/ids.json?user_id=123&screen_name=456&cursor=1&count=1"; var reqProc = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/" }; var parameters = new Dictionary<string, string> { { "Type", ((int)SocialGraphType.Followers).ToString() }, { "UserID", "123" }, { "ScreenName", "456" }, { "Cursor", "1" }, { "Count", "1" } }; Request req = reqProc.BuildUrl(parameters); Assert.Equal(ExpectedUrl, req.FullUrl); }
public void SavedSearchRequestProcessor_Works_On_Json_Format_Data() { var graphReqProc = new SocialGraphRequestProcessor <SocialGraph>(); Assert.IsAssignableFrom <IRequestProcessorWantsJson>(graphReqProc); }
public void BuildURLTest() { SocialGraphRequestProcessor<SocialGraph> target = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "http://twitter.com/" }; Dictionary<string, string> parameters = new Dictionary<string, string>(); string expected = "http://twitter.com/friends/ids.xml"; string actual; actual = target.BuildURL(parameters); Assert.AreEqual(expected, actual); }
public void ProcessResults_Populates_Input_Parameters() { var statProc = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/", Type = SocialGraphType.Friends, UserID = 123, ScreenName = "abc", Cursor = "-1", Count = 3, }; var graphResult = statProc.ProcessResults(TestQueryResponse); Assert.NotNull(graphResult); Assert.Single(graphResult); var graph = graphResult.Single(); Assert.NotNull(graph); Assert.Equal(SocialGraphType.Friends, graph.Type); Assert.Equal(123ul, graph.UserID); Assert.Equal("abc", graph.ScreenName); Assert.Equal("-1", graph.Cursor); Assert.Equal(3, graph.Count); }
public void GetParametersTest() { SocialGraphRequestProcessor<SocialGraph> target = new SocialGraphRequestProcessor<SocialGraph>(); Expression<Func<SocialGraph, bool>> expression = graph => graph.Type == SocialGraphType.Followers && graph.ID == "123" && graph.ScreenName == "456"; LambdaExpression lambdaExpression = expression as LambdaExpression; var queryParams = target.GetParameters(lambdaExpression); Assert.IsTrue( queryParams.Contains( new KeyValuePair<string, string>("Type", ((int)SocialGraphType.Followers).ToString()))); Assert.IsTrue( queryParams.Contains( new KeyValuePair<string, string>("ID", "123"))); Assert.IsTrue( queryParams.Contains( new KeyValuePair<string, string>("ScreenName", "456"))); }
public void NullParametersTest() { SocialGraphRequestProcessor<SocialGraph> target = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "http://twitter.com/" }; Dictionary<string, string> parameters = null; string actual; try { actual = target.BuildURL(parameters); Assert.Fail("Expected ArgumentException."); } catch (ArgumentException ae) { Assert.AreEqual<string>("Type", ae.ParamName); } }
public void ProcessResultsTest() { SocialGraphRequestProcessor<SocialGraph> target = new SocialGraphRequestProcessor<SocialGraph>(); XElement twitterResponse = XElement.Parse(m_testQueryResponse); IList actual = target.ProcessResults(twitterResponse); var graph = actual.Cast<SocialGraph>().ToList(); Assert.AreEqual(graph[0].IDs[0], "123456"); Assert.AreEqual(graph[0].IDs[1], "987654"); }
public void BuildUrl_Throws_On_Missing_Type() { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph>() { BaseUrl = "https://api.twitter.com/1.1/" }; var parameters = new Dictionary<string, string>(); var ex = Assert.Throws<ArgumentException>(() => graphReqProc.BuildUrl(parameters)); Assert.Equal("Type", ex.ParamName); }
public void BuildUrl_Throws_On_Null_Params() { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph> { BaseUrl = "https://api.twitter.com/1.1/" }; var ex = Assert.Throws<ArgumentException>(() => graphReqProc.BuildUrl(null)); Assert.Equal<string>("Type", ex.ParamName); }
public void SavedSearchRequestProcessor_Works_On_Json_Format_Data() { var graphReqProc = new SocialGraphRequestProcessor<SocialGraph>(); Assert.IsAssignableFrom<IRequestProcessorWantsJson>(graphReqProc); }