1.9 KiB
1.9 KiB
Svrnty.GeoManagement.Tests
Integration tests for the Svrnty.GeoManagement library.
Setup
The tests require a Google Maps API key to run the integration tests.
Step 1: Get a Google Maps API Key
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Geocoding API
- Create credentials (API Key)
- (Optional) Restrict the API key to only allow Geocoding API calls
Step 2: Configure the API Key
-
Copy
appsettings.Example.json
toappsettings.Development.json
:cp appsettings.Example.json appsettings.Development.json
-
Edit
appsettings.Development.json
and replaceYOUR_GOOGLE_API_KEY_HERE
with your actual API key:{ "GoogleGeoManagement": { "ApiKey": "AIza...", // Your actual API key "Language": "en", "Region": "us" } }
-
Important:
appsettings.Development.json
is in.gitignore
and will not be committed to version control.
Alternative: Using Environment Variables
You can also set the API key via environment variables:
export GoogleGeoManagement__ApiKey="your-api-key-here"
Note: Use double underscores (__
) to represent nested configuration sections.
Running Tests
dotnet test
The integration tests will make actual calls to the Google Geocoding API. Be aware of:
- API Rate Limits: Google has rate limits on API calls
- API Costs: While Google provides free tier usage, be aware of potential costs
- Network Dependency: Tests require an internet connection
Test Coverage
The test suite includes:
- Forward geocoding (address to coordinates)
- Reverse geocoding (coordinates to address)
- Address normalization (both object and string)
- Edge cases (invalid addresses, ocean coordinates)
All tests use real Google API calls to ensure the integration works correctly.