Skip to content

Commit 4fae827

Browse files
MapQuest: Add "charset=utf-8" to Content-Type (chadly#138)
Update tests for unicode, and add Async tests for MapQuest.
1 parent e329d90 commit 4fae827

4 files changed

Lines changed: 29 additions & 4 deletions

File tree

src/Geocoding.MapQuest/MapQuestGeocoder.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -170,7 +170,7 @@ private async Task<HttpWebRequest> Send(BaseRequest f, CancellationToken cancell
170170
break;
171171
}
172172
request.Method = f.RequestVerb;
173-
request.ContentType = "application/" + f.InputFormat;
173+
request.ContentType = "application/" + f.InputFormat + "; charset=utf-8";
174174

175175
if (Proxy != null)
176176
request.Proxy = Proxy;
@@ -270,4 +270,4 @@ ICollection<ResultItem> HandleBatchResponse(MapQuestResponse res)
270270
throw new NotSupportedException("ReverseGeocodeAsync(...) is not available for MapQuestGeocoder.");
271271
}
272272
}
273-
}
273+
}

test/Geocoding.Tests/AsyncGeocoderTest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ public async Task CanGeocodeWithSpecialCharacters()
6969
Assert.NotEmpty(addresses);
7070
}
7171

72+
[Fact]
73+
public async Task CanGeocodeWithUnicodeCharacters()
74+
{
75+
var addresses = await asyncGeocoder.GeocodeAsync("Étretat, France");
76+
Assert.NotEmpty(addresses);
77+
}
78+
7279
[Fact]
7380
public async Task CanReverseGeocodeAsync()
7481
{

test/Geocoding.Tests/GeocoderTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public virtual async Task ShouldNotBlowUpOnBadAddress()
7070
[InlineData("40 1/2 Road")]
7171
[InlineData("B's Farm RD")]
7272
[InlineData("Wilshire & Bundy Plaza, Los Angeles")]
73+
[InlineData("Étretat, France")]
7374
public virtual async Task CanGeocodeWithSpecialCharacters(string address)
7475
{
7576
Address[] addresses = (await geocoder.GeocodeAsync(address)).ToArray();
@@ -106,4 +107,4 @@ public virtual async Task CanGeocodeInvalidZipCodes(string address)
106107
Assert.NotEmpty(addresses);
107108
}
108109
}
109-
}
110+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Geocoding.MapQuest;
2+
using Xunit;
3+
4+
namespace Geocoding.Tests
5+
{
6+
[Collection("Settings")]
7+
public class MapQuestAsyncGeocoderTest : AsyncGeocoderTest
8+
{
9+
protected override IGeocoder CreateAsyncGeocoder()
10+
{
11+
return new MapQuestGeocoder(settings.MapQuestKey)
12+
{
13+
UseOSM = false
14+
};
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)