Ejemplo n.º 1
0
        public void FindSimilarPlaces()
        {
            mockServer.ExpectNewRequest()
            .AndExpectUri("https://api.twitter.com/1.1/geo/similar_places.json?lat=37.7821120598956&long=-122.400612831116&name=Twitter%20HQ&attribute%3Astreet_address=795%20Folsom%20St&contained_within=2e056b6d9c0ff3cd")
            .AndExpectMethod(HttpMethod.GET)
            .AndRespondWith(JsonResource("Similar_Places"), responseHeaders);

#if NET_4_0 || SILVERLIGHT_5
            SimilarPlaces similarPlaces = twitter.GeoOperations.FindSimilarPlacesAsync(37.7821120598956, -122.400612831116, "Twitter HQ", "795 Folsom St", "2e056b6d9c0ff3cd").Result;
#else
            SimilarPlaces similarPlaces = twitter.GeoOperations.FindSimilarPlaces(37.7821120598956, -122.400612831116, "Twitter HQ", "795 Folsom St", "2e056b6d9c0ff3cd");
#endif
            Assert.AreEqual("9c8072b2a6788ee530e8c8cbb487107c", similarPlaces.PlacePrototype.CreateToken);
            Assert.AreEqual(37.7821120598956, similarPlaces.PlacePrototype.Latitude, 0.0000001);
            Assert.AreEqual(-122.400612831116, similarPlaces.PlacePrototype.Longitude, 0.0000001);
            Assert.AreEqual("Twitter HQ", similarPlaces.PlacePrototype.Name);
            Assert.AreEqual("2e056b6d9c0ff3cd", similarPlaces.PlacePrototype.ContainedWithin);
            Assert.AreEqual(2, similarPlaces.Count);
            Assert.AreEqual("851a1ba23cb8c6ee", similarPlaces[0].ID);
            Assert.AreEqual("twitter", similarPlaces[0].Name);
            Assert.AreEqual("twitter, Twitter HQ", similarPlaces[0].FullName);
            Assert.IsNull(similarPlaces[0].StreetAddress);
            Assert.AreEqual("United States", similarPlaces[0].Country);
            Assert.AreEqual("US", similarPlaces[0].CountryCode);
            Assert.AreEqual(PlaceType.POI, similarPlaces[0].PlaceType);
            Assert.AreEqual("247f43d441defc03", similarPlaces[1].ID);
            Assert.AreEqual("Twitter HQ", similarPlaces[1].Name);
            Assert.AreEqual("Twitter HQ, San Francisco", similarPlaces[1].FullName);
            Assert.AreEqual("795 Folsom St", similarPlaces[1].StreetAddress);
            Assert.AreEqual("United States", similarPlaces[1].Country);
            Assert.AreEqual("US", similarPlaces[1].CountryCode);
            Assert.AreEqual(PlaceType.POI, similarPlaces[1].PlaceType);
        }
 public object Deserialize(JsonValue json, JsonMapper mapper)
 {
     SimilarPlaces similarPlaces = new SimilarPlaces(mapper.Deserialize<IList<Place>>(json));
     similarPlaces.PlacePrototype = new PlacePrototype();
     similarPlaces.PlacePrototype.CreateToken = json.GetValue("result").GetValue<string>("token");
     return similarPlaces;
 }
Ejemplo n.º 3
0
        public object Deserialize(JsonValue json, JsonMapper mapper)
        {
            SimilarPlaces similarPlaces = new SimilarPlaces(mapper.Deserialize <IList <Place> >(json));

            similarPlaces.PlacePrototype             = new PlacePrototype();
            similarPlaces.PlacePrototype.CreateToken = json.GetValue("result").GetValue <string>("token");
            return(similarPlaces);
        }
        public SimilarPlaces FindSimilarPlaces(double latitude, double longitude, string name, string streetAddress, string containedWithin)
        {
            NameValueCollection parameters    = this.BuildPlaceParameters(latitude, longitude, name, streetAddress, containedWithin);
            SimilarPlaces       similarPlaces = this.restTemplate.GetForObject <SimilarPlaces>(this.BuildUrl("geo/similar_places.json", parameters));

            similarPlaces.PlacePrototype.Latitude        = latitude;
            similarPlaces.PlacePrototype.Longitude       = longitude;
            similarPlaces.PlacePrototype.Name            = name;
            similarPlaces.PlacePrototype.StreetAddress   = streetAddress;
            similarPlaces.PlacePrototype.ContainedWithin = containedWithin;
            return(similarPlaces);
        }