67 lines
1.9 KiB
Markdown
67 lines
1.9 KiB
Markdown
# 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
|
|
|
|
1. Go to [Google Cloud Console](https://console.cloud.google.com/)
|
|
2. Create a new project or select an existing one
|
|
3. Enable the **Geocoding API**
|
|
4. Create credentials (API Key)
|
|
5. (Optional) Restrict the API key to only allow Geocoding API calls
|
|
|
|
### Step 2: Configure the API Key
|
|
|
|
1. Copy `appsettings.Example.json` to `appsettings.Development.json`:
|
|
```bash
|
|
cp appsettings.Example.json appsettings.Development.json
|
|
```
|
|
|
|
2. Edit `appsettings.Development.json` and replace `YOUR_GOOGLE_API_KEY_HERE` with your actual API key:
|
|
```json
|
|
{
|
|
"GoogleGeoManagement": {
|
|
"ApiKey": "AIza...", // Your actual API key
|
|
"Language": "en",
|
|
"Region": "us"
|
|
}
|
|
}
|
|
```
|
|
|
|
3. **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:
|
|
|
|
```bash
|
|
export GoogleGeoManagement__ApiKey="your-api-key-here"
|
|
```
|
|
|
|
Note: Use double underscores (`__`) to represent nested configuration sections.
|
|
|
|
## Running Tests
|
|
|
|
```bash
|
|
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.
|