void get_geocode_info() { context["geocode"] = () => { var testCoordinates = new DecimalCoordinatePairModel { Latitude = 40.714224m, Longitude = -73.961452m, }; itAsync["can save to cache"] = async() => { var expected = @"Williamsburg Brooklyn New York"; var testRoot = "./"; var helper = new CacheHelper(testRoot); await helper.ClearCache(); await helper.SaveToCache(testCoordinates, expected); var actual = await helper.ReadFromCache(testCoordinates); actual.Should().Be(expected); }; itAsync["can reverse geocode"] = async() => { var expected = @"Williamsburg Brooklyn New York"; var helper = new GeocodeHelper(); var actual = await helper.ReverseGeocode(testCoordinates); actual.Should().Be(expected); }; }; }
void get_exif_info() { context["exif info from photo"] = () => { var testFile = @"/home/dotnet/wwwroot/content/photos/TestImage.JPG"; it["can extract latitude and longitude"] = () => { var expected = @"N 33 53' 2.2"", E 130 52' 0.7"""; var helper = new ExInfoHelper(); var actual = helper.ExtractGeoCoordinatesText(testFile); actual.Should().Be(expected); }; it["can extract decimal coordinates"] = () => { var expected = new DecimalCoordinatePairModel { Latitude = 33.883938943142361111111111111m, Longitude = 130.86684746093750000000000000m, }; var helper = new ExInfoHelper(); var actual = helper.ExtractGeoCoordinates(testFile); actual.ShouldBeEquivalentTo(expected); }; }; context["photo without exif info"] = () => { var testFile = @"/home/dotnet/wwwroot/content/photos/woman.jpg"; it["returns empty string"] = () => { var expected = string.Empty; var helper = new ExInfoHelper(); var actual = helper.ExtractGeoCoordinatesText(testFile); actual.Should().Be(expected); }; it["returns 0,0 coordinates"] = () => { var expected = new DecimalCoordinatePairModel { Latitude = 0m, Longitude = 0m, }; var helper = new ExInfoHelper(); var actual = helper.ExtractGeoCoordinates(testFile); actual.ShouldBeEquivalentTo(expected); }; }; }