public void BasicTest() { const double latitudeOfBerlin = 52.518639; const double longitudeOfBerlin = 13.376090; var locationFactory = new GeoFactory(); var locationOfBerlin = locationFactory.CreateLocation(latitudeOfBerlin, longitudeOfBerlin); var googleMapsLink = locationOfBerlin.ToGoogleMapsLink(); var bingLink = locationOfBerlin.ToBingMapsLink(); var openStreetMapsLink = locationOfBerlin.ToOpenStreetMapsLink(); Assert.NotEmpty(googleMapsLink); Assert.NotEmpty(bingLink); Assert.NotEmpty(openStreetMapsLink); }
public void TestCreateLocation() { var fac = new GeoFactory(); var loc = fac.CreateLocation(0.0, 0.0); Assert.Equal(0.0, loc.Latitude); Assert.Equal(0.0, loc.Longitude); // passive assert: this lines must not throw an exception fac.CreateLocation(-90.0, -180); // min. values fac.CreateLocation(90.0, 180.0); // max. values Assert.Throws <ArgumentOutOfRangeException>(() => fac.CreateLocation(-90.1, 0.0)); Assert.Throws <ArgumentOutOfRangeException>(() => fac.CreateLocation(90.1, 0)); Assert.Throws <ArgumentOutOfRangeException>(() => fac.CreateLocation(0, -180.1)); Assert.Throws <ArgumentOutOfRangeException>(() => fac.CreateLocation(0, 180.1)); }
public void TestGeoLocationFactory() { var factory = new GeoFactory(); var geoBerlin = factory.CreateLocation(DecimalLatitudeOfBerlin, DecimalLongitudeOfBerlin); var latBerlin = geoBerlin.LatitudeDMS; var lonBerlin = geoBerlin.LongitudeDMS; Assert.Equal(52, latBerlin.Degrees); Assert.Equal(31, latBerlin.Minutes); Assert.Equal(7.1, Math.Round(latBerlin.Seconds, 3, MidpointRounding.AwayFromZero)); Assert.Equal(13, lonBerlin.Degrees); Assert.Equal(22, lonBerlin.Minutes); Assert.Equal(33.924, Math.Round(lonBerlin.Seconds, 3, MidpointRounding.AwayFromZero)); Assert.Equal("N 52° 31' 07.1\"", geoBerlin.LatitudeDMS.WriteToString()); Assert.Equal("E 13° 22' 33.9\"", geoBerlin.LongitudeDMS.WriteToString()); geoBerlin.LongitudeDMS.WriteToString(); }