forked from chadly/Geocoding.net
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBatchGeocoderTest.cs
More file actions
69 lines (56 loc) · 1.49 KB
/
BatchGeocoderTest.cs
File metadata and controls
69 lines (56 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
using Xunit.Extensions;
namespace Geocoding.Tests
{
public abstract class BatchGeocoderTest
{
readonly IBatchGeocoder batchGeocoder;
public BatchGeocoderTest()
{
//Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");
batchGeocoder = CreateBatchGeocoder();
}
protected abstract IBatchGeocoder CreateBatchGeocoder();
[Theory]
[MemberData("BatchGeoCodeData")]
public virtual async Task CanGeoCodeAddress(string[] addresses)
{
Assert.NotEmpty(addresses);
IEnumerable<ResultItem> results = await batchGeocoder.GeocodeAsync(addresses);
Assert.NotEmpty(results);
Assert.Equal(addresses.Length, results.Count());
var ahash = new HashSet<string>(addresses);
Assert.Equal(ahash.Count, results.Count());
foreach (ResultItem r in results)
{
Assert.NotNull(r);
Assert.NotNull(r.Request);
Assert.NotNull(r.Response);
Assert.Contains(r.Request.FormattedAddress, ahash);
Address[] respa = r.Response.ToArray();
Assert.NotEmpty(respa);
ahash.Remove(r.Request.FormattedAddress);
}
Assert.Empty(ahash);
}
public static IEnumerable<object[]> BatchGeoCodeData
{
get
{
yield return new object[]
{
new string[]
{
"1600 pennsylvania ave nw, washington dc",
"1460 4th Street Ste 304, Santa Monica CA 90401",
},
};
}
}
}
}