Exemple #1
0
        public void ProcessResults_Handles_Closest()
        {
            var trendReqProc = new TrendRequestProcessor <Trend> {
                Type = TrendType.Closest
            };

            List <Trend> trendList = trendReqProc.ProcessResults(TestAvailableOrClosestQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.SingleOrDefault();

            Assert.NotNull(trends);
            var locations = trends.Locations;

            Assert.NotNull(locations);
            Assert.Equal(2, locations.Count);
            Location location = locations[1];

            Assert.NotNull(location);
            Assert.Equal("Town", location.PlaceTypeName);
            Assert.Equal(7, location.PlaceTypeNameCode);
            Assert.Equal("Birmingham", location.Name);
            Assert.Equal("http://where.yahooapis.com/v1/place/2364559", location.Url);
            Assert.Equal(2364559, location.WoeID);
            Assert.Equal("US", location.CountryCode);
            Assert.Equal("23424977", location.ParentID);
            Assert.Equal("United States", location.Country);
        }
Exemple #2
0
        public void ProcessResults_Handles_Available()
        {
            var trendReqProc = new TrendRequestProcessor <Trend> {
                Type = TrendType.Available
            };

            List <Trend> trendList = trendReqProc.ProcessResults(TestAvailableOrClosestQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.SingleOrDefault();

            Assert.NotNull(trends);
            var locations = trends.Locations;

            Assert.NotNull(locations);
            Assert.Equal(2, locations.Count);
            Location location = locations[0];

            Assert.Equal("Country", location.PlaceTypeName);
            Assert.Equal(12, location.PlaceTypeNameCode);
            Assert.Equal("Turkey", location.Name);
            Assert.Equal("http://where.yahooapis.com/v1/place/23424969", location.Url);
            Assert.Equal(23424969, location.WoeID);
            Assert.Equal("TR", location.CountryCode);
            Assert.Equal("1", location.ParentID);
            Assert.Equal("Turkey", location.Country);
        }
Exemple #3
0
        public void ProcessResults_Parses_Location()
        {
            var trendProc = new TrendRequestProcessor <Trend> {
                Type = TrendType.Place
            };

            List <Trend> trendList = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.FirstOrDefault();

            Assert.NotNull(trends);
            var locations = trends.Locations;

            Assert.NotNull(locations);
            Assert.Equal(1, locations.Count);
            Location location = locations[0];

            Assert.Equal("Worldwide", location.Name);
            Assert.Equal(1, location.WoeID);
            Assert.Equal("%22Julianna%20Margulies%22", trends.Query);
            Assert.Equal("Julianna Margulies", trends.Name);
            Assert.Null(trends.PromotedContent);
            Assert.Equal("http://twitter.com/search/%22Julianna%20Margulies%22", trends.SearchUrl);
            Assert.Null(trends.Events);
            Assert.Equal(new DateTime(2011, 9, 19, 2, 4, 39), trends.AsOf);
            Assert.Equal(new DateTime(2011, 9, 19, 2, 0, 17), trends.CreatedAt);
        }
Exemple #4
0
        public void GetParameters_Collects_Parameters()
        {
            var trendReqProc = new TrendRequestProcessor <Trend>();
            Expression <Func <Trend, bool> > expression =
                trend =>
                trend.Type == TrendType.Available &&
                trend.WoeID == 1 &&
                trend.Latitude == "1.2" &&
                trend.Longitude == "3.4" &&
                trend.Exclude == true;
            var lambdaExpression = expression as LambdaExpression;

            var queryParams = trendReqProc.GetParameters(lambdaExpression);

            Assert.True(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Type", ((int)TrendType.Available).ToString(CultureInfo.InvariantCulture))));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair <string, string>("WoeID", "1")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Latitude", "1.2")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Longitude", "3.4")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Exclude", "True")));
        }
        public void GetParameters_Collects_Parameters()
        {
            var trendReqProc = new TrendRequestProcessor<Trend>();
            Expression<Func<Trend, bool>> expression =
                trend =>
                    trend.Type == TrendType.Available &&
                    trend.WoeID == 1 &&
                    trend.Latitude == "1.2" &&
                    trend.Longitude == "3.4" &&
                    trend.Exclude == true;
            var lambdaExpression = expression as LambdaExpression;

            var queryParams = trendReqProc.GetParameters(lambdaExpression);

            Assert.True(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Type", ((int)TrendType.Available).ToString(CultureInfo.InvariantCulture))));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair<string, string>("WoeID", "1")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Latitude", "1.2")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Longitude", "3.4")));
            Assert.True(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Exclude", "True")));
        }
Exemple #6
0
        public void ProcessResults_Returns_Empty_Collection_When_Empty_Results()
        {
            var trendProc = new TrendRequestProcessor <Trend>();

            var trends = trendProc.ProcessResults(string.Empty);

            Assert.Equal(0, trends.Count);
        }
        public void ProcessAvailableTrendResultsTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>();
            XElement twitterResponse             = XElement.Parse(m_testAvailableQueryResponse);
            IList    actual = target.ProcessResults(twitterResponse);
            var      trends = actual.Cast <Trend>().ToList();

            Assert.AreEqual(10, trends[0].Locations.Count);
        }
Exemple #8
0
        public void BuildUrl_Throws_With_No_Parameters()
        {
            var trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };

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

            Assert.Equal("Type", ex.ParamName);
        }
        public void ProcessCurrentTrendResultsTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>();
            XElement twitterResponse             = XElement.Parse(m_testCurrentTrendQueryResponse);
            IList    actual = target.ProcessResults(twitterResponse);
            var      trends = actual.Cast <Trend>().ToList();

            Assert.AreEqual(10, trends.Count);
            Assert.AreNotEqual(DateTime.MinValue.Date, trends[0].AsOf.Date);
        }
Exemple #10
0
        public void BuildUrl_Throws_When_Type_Not_Provided()
        {
            var trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters = new Dictionary <string, string>();

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

            Assert.Equal("Type", ex.ParamName);
        }
 public void BuildLocationTrendsWithoutWeoIDURLTest()
 {
     TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
     {
         BaseUrl = "http://api.twitter.com/1/"
     };
     Dictionary <string, string> parameters =
         new Dictionary <string, string>
     {
         { "Type", ((int)TrendType.Location).ToString() },
     };
     string actual = target.BuildURL(parameters);
 }
        public void BuildUrl_Handles_Available_Trends()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/trends/available.json";
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)TrendType.Available).ToString(CultureInfo.InvariantCulture) }
                };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
Exemple #13
0
        public void BuildUrl_Throws_On_Place_Trends_WithoutWoeID()
        {
            var trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Place).ToString(CultureInfo.InvariantCulture) },
            };

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

            Assert.Equal("WoeID", ex.ParamName);
        }
        public void BuildAvailableTrendsWithoutLatitudeURLTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Available).ToString() },
                { "Longitude", "-122.40060" }
            };

            target.BuildURL(parameters);
        }
Exemple #15
0
        public void BuildUrl_Constructs_AvailableTrends_Url()
        {
            const string ExpectedUrl  = "https://api.twitter.com/1.1/trends/available.json";
            var          trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Available).ToString(CultureInfo.InvariantCulture) }
            };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
Exemple #16
0
        public void BuildUrl_Constructs_Place_Trends_Url()
        {
            const string ExpectedUrl  = "https://api.twitter.com/1.1/trends/place.json?id=1";
            var          trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Place).ToString(CultureInfo.InvariantCulture) },
                { "WoeID", "1" }
            };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.AreEqual(ExpectedUrl, req.FullUrl);
        }
        public void BuildTrendsURLTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://search.twitter.com/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Trend).ToString() }
            };
            string expected = "http://search.twitter.com/trends.json";
            string actual;

            actual = target.BuildURL(parameters);
            Assert.AreEqual(expected, actual);
        }
Exemple #18
0
        public void BuildUrl_Constructs_ClosestTrends_Url()
        {
            const string ExpectedUrl  = "https://api.twitter.com/1.1/trends/closest.json?lat=37.78215&long=-122.40060";
            var          trendReqProc = new TrendRequestProcessor <Trend> {
                BaseUrl = "https://api.twitter.com/1.1/"
            };
            var parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Closest).ToString(CultureInfo.InvariantCulture) },
                { "Latitude", "37.78215" },
                { "Longitude", "-122.40060" }
            };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
        public void BuildLocationTrendsURLTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Location).ToString() },
                { "WeoID", "1" }
            };
            string expected = "http://api.twitter.com/1/trends/1.xml";
            string actual;

            actual = target.BuildURL(parameters);
            Assert.AreEqual(expected, actual);
        }
        public void BuildDailyTrendsURLTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://search.twitter.com/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Daily).ToString() },
                { "Date", "2009-01-01" },
                { "ExcludeHashtags", "true" }
            };
            string expected = "http://search.twitter.com/trends/daily.json?date=2009-01-01&exclude=hashtags";
            string actual;

            actual = target.BuildURL(parameters);
            Assert.AreEqual(expected, actual);
        }
        public void NullParametersTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://search.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 BuildAvailableTrendsURLTest()
        {
            TrendRequestProcessor <Trend> target = new TrendRequestProcessor <Trend>()
            {
                BaseUrl = "http://api.twitter.com/1/"
            };
            Dictionary <string, string> parameters =
                new Dictionary <string, string>
            {
                { "Type", ((int)TrendType.Available).ToString() },
                { "Latitude", "37.78215" },
                { "Longitude", "-122.40060" }
            };
            string expected = "http://api.twitter.com/1/trends/available.xml?lat=37.78215&long=-122.40060";
            string actual;

            actual = target.BuildURL(parameters);
            Assert.AreEqual(expected, actual);
        }
        public void GetParametersTest()
        {
            var currDT = DateTime.Now;

            TrendRequestProcessor <Trend>    target     = new TrendRequestProcessor <Trend>();
            Expression <Func <Trend, bool> > expression =
                trend =>
                trend.Type == TrendType.Current &&
                trend.ExcludeHashtags == true;
            LambdaExpression lambdaExpression = expression as LambdaExpression;

            var queryParams = target.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("Type", ((int)TrendType.Current).ToString())));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair <string, string>("ExcludeHashtags", "True")));
        }
        public void ProcessResults_Populates_Input_Parameters()
        {
            var trendProc = new TrendRequestProcessor<Trend>()
            {
                BaseUrl = "https://api.twitter.com/1.1/",
                Type = TrendType.Place,
                Exclude = true,
                Latitude = "1.1",
                Longitude = "2.2",
                WoeID = 1
            };

            var trends = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.NotNull(trends);
            Assert.NotEmpty(trends);
            var trend = trends.First();
            Assert.NotNull(trend);
            Assert.True(trend.Exclude);
            Assert.Equal("1.1", trend.Latitude);
            Assert.Equal("2.2", trend.Longitude);
            Assert.Equal(1, trend.WoeID);
        }
        public void ProcessResults_Populates_Input_Parameters()
        {
            var trendProc = new TrendRequestProcessor<Trend>()
            {
                BaseUrl = "https://api.twitter.com/1.1/",
                Type = TrendType.Place,
                Exclude = true,
                Latitude = 1.1,
                Longitude = 2.2,
                WoeID = 1
            };

            List<Trend> trends = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.IsNotNull(trends);
            Assert.IsTrue(trends.Any());
            Trend trend = trends.First();
            Assert.IsNotNull(trend);
            Assert.IsTrue(trend.Exclude);
            Assert.AreEqual(1.1, trend.Latitude);
            Assert.AreEqual(2.2, trend.Longitude);
            Assert.AreEqual(1, trend.WoeID);
        }
Exemple #26
0
        public void ProcessResults_Populates_Input_Parameters()
        {
            var trendProc = new TrendRequestProcessor <Trend>()
            {
                BaseUrl   = "https://api.twitter.com/1.1/",
                Type      = TrendType.Place,
                Exclude   = true,
                Latitude  = 1.1,
                Longitude = 2.2,
                WoeID     = 1
            };

            List <Trend> trends = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.IsNotNull(trends);
            Assert.IsTrue(trends.Any());
            Trend trend = trends.First();

            Assert.IsNotNull(trend);
            Assert.IsTrue(trend.Exclude);
            Assert.AreEqual(1.1, trend.Latitude);
            Assert.AreEqual(2.2, trend.Longitude);
            Assert.AreEqual(1, trend.WoeID);
        }
Exemple #27
0
        public void ProcessResults_Populates_Input_Parameters()
        {
            var trendProc = new TrendRequestProcessor <Trend>()
            {
                BaseUrl   = "https://api.twitter.com/1.1/",
                Type      = TrendType.Place,
                Exclude   = true,
                Latitude  = "1.1",
                Longitude = "2.2",
                WoeID     = 1
            };

            var trends = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.NotNull(trends);
            Assert.NotEmpty(trends);
            var trend = trends.First();

            Assert.NotNull(trend);
            Assert.True(trend.Exclude);
            Assert.Equal("1.1", trend.Latitude);
            Assert.Equal("2.2", trend.Longitude);
            Assert.Equal(1, trend.WoeID);
        }
 public void BuildAvailableTrendsWithoutLatitudeURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://api.twitter.com/1/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Available).ToString() },
             { "Longitude", "-122.40060" }
         };
     target.BuildURL(parameters);
 }
 public void BuildLocationTrendsURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://api.twitter.com/1/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Location).ToString() },
             { "WeoID", "1" }
         };
     string expected = "http://api.twitter.com/1/trends/1.xml";
     string actual;
     actual = target.BuildURL(parameters);
     Assert.AreEqual(expected, actual);
 }
 public void BuildLocationTrendsWithoutWeoIDURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://api.twitter.com/1/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Location).ToString() },
         };
     string actual = target.BuildURL(parameters);
 }
 public void BuildTrendsURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://search.twitter.com/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Trend).ToString() }
         };
     string expected = "http://search.twitter.com/trends.json";
     string actual;
     actual = target.BuildURL(parameters);
     Assert.AreEqual(expected, actual);
 }
 public void BuildWeeklyTrendsURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://search.twitter.com/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Weekly).ToString() },
             { "Date", "2009-01-01" },
             { "ExcludeHashtags", "true" }
         };
     string expected = "http://search.twitter.com/trends/weekly.json?date=2009-01-01&exclude=hashtags";
     string actual;
     actual = target.BuildURL(parameters);
     Assert.AreEqual(expected, actual);
 }
        public void GetParametersTest()
        {
            var currDT = DateTime.Now;

            TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>();
            Expression<Func<Trend, bool>> expression =
                trend =>
                    trend.Type == TrendType.Current &&
                    trend.ExcludeHashtags == true;
            LambdaExpression lambdaExpression = expression as LambdaExpression;

            var queryParams = target.GetParameters(lambdaExpression);

            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("Type", ((int)TrendType.Current).ToString())));
            Assert.IsTrue(
                queryParams.Contains(
                    new KeyValuePair<string, string>("ExcludeHashtags", "True")));
        }
        public void BuildUrl_Constructs_Place_Trends_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/trends/place.json?id=1";
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)TrendType.Place).ToString(CultureInfo.InvariantCulture) },
                    { "WoeID", "1" }
                };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
        public void ProcessResults_Parses_Location()
        {
            var trendProc = new TrendRequestProcessor<Trend> { Type = TrendType.Place };

            List<Trend> trendList = trendProc.ProcessResults(TestTrendQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.FirstOrDefault();
            Assert.NotNull(trends);
            var locations = trends.Locations;
            Assert.NotNull(locations);
            Assert.Equal(1, locations.Count);
            Location location = locations[0];
            Assert.Equal("Worldwide", location.Name);
            Assert.Equal("1", location.WoeID);
            Assert.Equal("%22Julianna%20Margulies%22", trends.Query);
            Assert.Equal("Julianna Margulies", trends.Name);
            Assert.Null(trends.PromotedContent);
            Assert.Equal("http://twitter.com/search/%22Julianna%20Margulies%22", trends.SearchUrl);
            Assert.Null(trends.Events);
            Assert.Equal(new DateTime(2011, 9, 19, 2, 4, 39), trends.AsOf);
            Assert.Equal(new DateTime(2011, 9, 19, 2, 0, 17), trends.CreatedAt);
        }
        public void ProcessResults_Handles_Available()
        {
            var trendReqProc = new TrendRequestProcessor<Trend> { Type = TrendType.Available };

            List<Trend> trendList = trendReqProc.ProcessResults(TestAvailableOrClosestQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.SingleOrDefault();
            Assert.NotNull(trends);
            var locations = trends.Locations;
            Assert.NotNull(locations);
            Assert.Equal(2, locations.Count);
            Location location = locations[0];
            Assert.Equal("Country", location.PlaceTypeName);
            Assert.Equal(12, location.PlaceTypeNameCode);
            Assert.Equal("Turkey", location.Name);
            Assert.Equal("http://where.yahooapis.com/v1/place/23424969", location.Url);
            Assert.Equal("23424969", location.WoeID);
            Assert.Equal("TR", location.CountryCode);
            Assert.Equal("1", location.ParentID);
            Assert.Equal("Turkey", location.Country);
        }
        public void ProcessResults_Handles_Closest()
        {
            var trendReqProc = new TrendRequestProcessor<Trend> { Type = TrendType.Closest };

            List<Trend> trendList = trendReqProc.ProcessResults(TestAvailableOrClosestQueryResponse);

            Assert.NotNull(trendList);
            var trends = trendList.SingleOrDefault();
            Assert.NotNull(trends);
            var locations = trends.Locations;
            Assert.NotNull(locations);
            Assert.Equal(2, locations.Count);
            Location location = locations[1];
            Assert.NotNull(location);
            Assert.Equal("Town", location.PlaceTypeName);
            Assert.Equal(7, location.PlaceTypeNameCode);
            Assert.Equal("Birmingham", location.Name);
            Assert.Equal("http://where.yahooapis.com/v1/place/2364559", location.Url);
            Assert.Equal("2364559", location.WoeID);
            Assert.Equal("US", location.CountryCode);
            Assert.Equal("23424977", location.ParentID);
            Assert.Equal("United States", location.Country);
        }
        public void BuildUrl_Throws_With_No_Parameters()
        {
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };

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

            Assert.Equal("Type", ex.ParamName);
        }
        public void BuildUrl_Throws_When_Type_Not_Provided()
        {
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters = new Dictionary<string, string>();

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

            Assert.Equal("Type", ex.ParamName);
        }
        public void BuildUrl_Throws_On_Place_Trends_WithoutWoeID()
        {
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)TrendType.Place).ToString(CultureInfo.InvariantCulture) },
                };

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

            Assert.Equal("WoeID", ex.ParamName);
        }
 public void BuildAvailableTrendsURLTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://api.twitter.com/1/" };
     Dictionary<string, string> parameters =
         new Dictionary<string, string>
         {
             { "Type", ((int)TrendType.Available).ToString() },
             { "Latitude", "37.78215" },
             { "Longitude", "-122.40060" }
         };
     string expected = "http://api.twitter.com/1/trends/available.xml?lat=37.78215&long=-122.40060";
     string actual;
     actual = target.BuildURL(parameters);
     Assert.AreEqual(expected, actual);
 }
 public void ProcessAvailableTrendResultsTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>();
     XElement twitterResponse = XElement.Parse(m_testAvailableQueryResponse);
     IList actual = target.ProcessResults(twitterResponse);
     var trends = actual.Cast<Trend>().ToList();
     Assert.AreEqual(10, trends[0].Locations.Count);
 }
        public void ProcessResults_Returns_Empty_Collection_When_Empty_Results()
        {
            var trendProc = new TrendRequestProcessor<Trend>();

            var trends = trendProc.ProcessResults(string.Empty);

            Assert.Equal(0, trends.Count);
        }
        public void BuildUrl_Constructs_ClosestTrends_Url()
        {
            const string ExpectedUrl = "https://api.twitter.com/1.1/trends/closest.json?lat=37.78215&long=-122.40060";
            var trendReqProc = new TrendRequestProcessor<Trend> { BaseUrl = "https://api.twitter.com/1.1/" };
            var parameters =
                new Dictionary<string, string>
                {
                    { "Type", ((int)TrendType.Closest).ToString(CultureInfo.InvariantCulture) },
                    { "Latitude", "37.78215" },
                    { "Longitude", "-122.40060" }
                };

            Request req = trendReqProc.BuildUrl(parameters);

            Assert.Equal(ExpectedUrl, req.FullUrl);
        }
 public void NullParametersTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>() { BaseUrl = "http://search.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 ProcessTrendResultsTest()
 {
     TrendRequestProcessor<Trend> target = new TrendRequestProcessor<Trend>();
     XElement twitterResponse = XElement.Parse(m_testTrendQueryResponse);
     IList actual = target.ProcessResults(twitterResponse);
     var trends = actual.Cast<Trend>().ToList();
     Assert.AreEqual(10, trends.Count);
     Assert.AreNotEqual(DateTime.MinValue.Date, trends[0].AsOf.Date);
 }