1- using System . Linq ;
1+ using System . Globalization ;
2+ using System . Linq ;
23using System . Threading . Tasks ;
34using Xunit ;
45
@@ -11,87 +12,68 @@ public abstract class AsyncGeocoderTest
1112
1213 public AsyncGeocoderTest ( )
1314 {
14- //Thread.CurrentThread. CurrentCulture = CultureInfo.GetCultureInfo ("en-us");
15+ CultureInfo . CurrentCulture = new CultureInfo ( "en-us" ) ;
1516
1617 asyncGeocoder = CreateAsyncGeocoder ( ) ;
1718 }
1819
1920 protected abstract IGeocoder CreateAsyncGeocoder ( ) ;
2021
2122 [ Fact ]
22- public void CanGeocodeAddress ( )
23+ public async Task CanGeocodeAddress ( )
2324 {
24- asyncGeocoder . GeocodeAsync ( "1600 pennsylvania ave washington dc" ) . ContinueWith ( task =>
25- {
26- Address [ ] addresses = task . Result . ToArray ( ) ;
27- addresses [ 0 ] . AssertWhiteHouse ( ) ;
28- } ) ;
25+ var addresses = await asyncGeocoder . GeocodeAsync ( "1600 pennsylvania ave washington dc" ) ;
26+ addresses . First ( ) . AssertWhiteHouse ( ) ;
2927 }
3028
3129 [ Fact ]
32- public void CanGeocodeNormalizedAddress ( )
30+ public async Task CanGeocodeNormalizedAddress ( )
3331 {
34- asyncGeocoder . GeocodeAsync ( "1600 pennsylvania ave" , "washington" , "dc" , null , null ) . ContinueWith ( task =>
35- {
36- Address [ ] addresses = task . Result . ToArray ( ) ;
37- addresses [ 0 ] . AssertWhiteHouse ( ) ;
38- } ) ;
32+ var addresses = await asyncGeocoder . GeocodeAsync ( "1600 pennsylvania ave" , "washington" , "dc" , null , null ) ;
33+ addresses . First ( ) . AssertWhiteHouse ( ) ;
3934 }
4035
4136 [ Theory ]
4237 [ InlineData ( "en-US" ) ]
4338 [ InlineData ( "cs-CZ" ) ]
4439 public async Task CanGeocodeAddressUnderDifferentCultures ( string cultureName )
4540 {
46- //Thread.CurrentThread. CurrentCulture = CultureInfo.GetCultureInfo (cultureName);
41+ CultureInfo . CurrentCulture = new CultureInfo ( cultureName ) ;
4742
48- var result = await asyncGeocoder . GeocodeAsync ( "24 sussex drive ottawa, ontario" ) ;
49- Address [ ] addresses = result . ToArray ( ) ;
50- addresses [ 0 ] . AssertCanadianPrimeMinister ( ) ;
43+ var addresses = await asyncGeocoder . GeocodeAsync ( "24 sussex drive ottawa, ontario" ) ;
44+ addresses . First ( ) . AssertCanadianPrimeMinister ( ) ;
5145 }
5246
5347 [ Theory ]
5448 [ InlineData ( "en-US" ) ]
5549 [ InlineData ( "cs-CZ" ) ]
5650 public async Task CanReverseGeocodeAddressUnderDifferentCultures ( string cultureName )
5751 {
58- //Thread.CurrentThread. CurrentCulture = CultureInfo.GetCultureInfo (cultureName);
52+ CultureInfo . CurrentCulture = new CultureInfo ( cultureName ) ;
5953
60- var result = await asyncGeocoder . ReverseGeocodeAsync ( 38.8976777 , - 77.036517 ) ;
61- Address [ ] addresses = result . ToArray ( ) ;
62- addresses [ 0 ] . AssertWhiteHouseArea ( ) ;
54+ var addresses = await asyncGeocoder . ReverseGeocodeAsync ( 38.8976777 , - 77.036517 ) ;
55+ addresses . First ( ) . AssertWhiteHouseArea ( ) ;
6356 }
6457
6558 [ Fact ]
66- public void ShouldNotBlowUpOnBadAddress ( )
59+ public async Task ShouldNotBlowUpOnBadAddress ( )
6760 {
68- asyncGeocoder . GeocodeAsync ( "sdlkf;jasl;kjfldksjfasldf" ) . ContinueWith ( task =>
69- {
70- var addresses = task . Result ;
71- Assert . Empty ( addresses ) ;
72- } ) ;
61+ var addresses = await asyncGeocoder . GeocodeAsync ( "sdlkf;jasl;kjfldksjfasldf" ) ;
62+ Assert . Empty ( addresses ) ;
7363 }
7464
7565 [ Fact ]
76- public void CanGeocodeWithSpecialCharacters ( )
66+ public async Task CanGeocodeWithSpecialCharacters ( )
7767 {
78- asyncGeocoder . GeocodeAsync ( "Fried St & 2nd St, Gretna, LA 70053" ) . ContinueWith ( task =>
79- {
80- var addresses = task . Result ;
81-
82- //asserting no exceptions are thrown and that we get something
83- Assert . NotEmpty ( addresses ) ;
84- } ) ;
68+ var addresses = await asyncGeocoder . GeocodeAsync ( "Fried St & 2nd St, Gretna, LA 70053" ) ;
69+ Assert . NotEmpty ( addresses ) ;
8570 }
8671
8772 [ Fact ]
88- public void CanReverseGeocodeAsync ( )
73+ public async Task CanReverseGeocodeAsync ( )
8974 {
90- asyncGeocoder . ReverseGeocodeAsync ( 38.8976777 , - 77.036517 ) . ContinueWith ( task =>
91- {
92- Address [ ] addresses = task . Result . ToArray ( ) ;
93- addresses [ 0 ] . AssertWhiteHouseArea ( ) ;
94- } ) ;
75+ var addresses = await asyncGeocoder . ReverseGeocodeAsync ( 38.8976777 , - 77.036517 ) ;
76+ addresses . First ( ) . AssertWhiteHouse ( ) ;
9577 }
9678 }
9779}
0 commit comments