public void TestConversion() { Location location = new Location() { Latitude = LocationTests.TestLatitude, Longitude = LocationTests.TestLongitude }; GeoCoordinate coord = location.ToGeoCoordinate(); Assert.AreEqual(location.Latitude, coord.Latitude, "Expected same Latitude"); Assert.AreEqual(location.Longitude, coord.Longitude, "Expected same Longitude"); }
public void TestOverrides() { Location location = new Location() { Latitude = TestLatitude, Longitude = TestLongitude }; Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, Location.LocationFormat, location.Latitude, location.Longitude), location.ToString(), "Expected format to be the same"); Assert.IsNotNull(location.GetHashCode(), "Expected a hash code"); Assert.IsFalse(location.Equals(TestLatitude), "Expected inequality"); }
public void EnsureLocationConverterConvertsToAGeoCoordinate() { Location location = new Location() { Latitude = TestLatitude, Longitude = TestLongitude }; LocationConverter converter = new LocationConverter(); GeoCoordinate coord = converter.Convert(location, typeof(GeoCoordinate), null, null) as GeoCoordinate; Assert.AreEqual(location.Latitude, coord.Latitude, "Expected same Latitude"); Assert.AreEqual(location.Longitude, coord.Longitude, "Expected same Longitude"); }
public void TestFullProperties() { Location location = new Location() { Latitude = TestLatitude, Longitude = TestLongitude, Name = TestName }; Assert.AreEqual(TestLatitude, location.Latitude, "Expected the property to persist"); Assert.AreEqual(TestLongitude, location.Longitude, "Expected the property to persist"); Assert.AreEqual(TestName, location.Name, "Expected the property to persist"); }
public void TestJsonParsing() { Assert.IsNull(Location.FromJToken(null), "Expected a null return"); var badLocation = JObject.Parse("{\"location\": null }"); Assert.IsNull(Location.FromJToken(badLocation["location"]), "Expected a null return"); Location location = new Location() { Latitude = TestLatitude, Longitude = TestLongitude, Name = TestName }; JObject json = JObject.Parse("{\"lat\":1.2345,\"lng\":2.3456,\"name\":\"name\"}"); Location fromJson = Location.FromJToken(json); Assert.IsNotNull(fromJson, "Expected a event object"); Assert.AreEqual(fromJson.Latitude, location.Latitude, "Expected the property to persist"); Assert.AreEqual(fromJson.Longitude, location.Longitude, "Expected the property to persist"); Assert.AreEqual(fromJson.Name, location.Name, "Expected the property to persist"); }
private static Location GetOrigin(JToken item) { Location origin = null; JToken originToken = item["origin"]; if (originToken != null) { string name = originToken.Value<string>("name"); JToken location = originToken["location"]; if (location != null) { origin = new Location() { Latitude = location.Value<double>("lat"), Longitude = location.Value<double>("lng"), Name = name }; } } return origin; }