@@ -17,40 +17,45 @@ public class CountryDataValidationTest
1717 [ TestMethod ]
1818 public async Task CompareWithMledozeCountryProject ( )
1919 {
20- using ( var httpClient = new HttpClient ( ) )
20+ var ignoreCountryCodes = new Alpha2Code [ ] { Alpha2Code . XK } ;
21+
22+ using var httpClient = new HttpClient ( ) ;
23+ var json = await httpClient . GetStringAsync ( "https://raw.githubusercontent.com/mledoze/countries/master/dist/countries.json" ) ;
24+ var items = JsonConvert . DeserializeObject < MledozeCountry [ ] > ( json ) ;
25+
26+ ICountryProvider countryProvider = new CountryProvider ( ) ;
27+ foreach ( var countryCode in ( Alpha2Code [ ] ) Enum . GetValues ( typeof ( Alpha2Code ) ) )
2128 {
22- var json = await httpClient . GetStringAsync ( "https://raw.githubusercontent.com/mledoze/countries/master/dist/countries.json" ) ;
23- var items = JsonConvert . DeserializeObject < MledozeCountry [ ] > ( json ) ;
29+ if ( ignoreCountryCodes . Contains ( countryCode ) )
30+ {
31+ continue ;
32+ }
2433
25- ICountryProvider countryProvider = new CountryProvider ( ) ;
26- foreach ( var countryCode in ( Alpha2Code [ ] ) Enum . GetValues ( typeof ( Alpha2Code ) ) )
34+ var countryInfo = countryProvider . GetCountry ( countryCode ) ;
35+ Trace . WriteLine ( $ "check { countryInfo . CommonName } ") ;
36+ if ( countryInfo is null )
2737 {
28- var countryInfo = countryProvider . GetCountry ( countryCode ) ;
29- Trace . WriteLine ( $ "check { countryInfo . CommonName } ") ;
30- if ( countryInfo is null )
31- {
32- Assert . Fail ( $ "countryInfo is null for { countryCode } ") ;
33- }
38+ Assert . Fail ( $ "countryInfo is null for { countryCode } ") ;
39+ }
3440
35- var compareCountry = items . FirstOrDefault ( o => o . Cca2 . Equals ( countryInfo . Alpha2Code . ToString ( ) ) ) ;
36- if ( compareCountry is null )
37- {
38- Assert . Inconclusive ( countryCode . ToString ( ) ) ;
39- continue ;
40- }
41+ var compareCountry = items . FirstOrDefault ( o => o . Cca2 . Equals ( countryInfo . Alpha2Code . ToString ( ) ) ) ;
42+ if ( compareCountry is null )
43+ {
44+ Assert . Inconclusive ( countryCode . ToString ( ) ) ;
45+ continue ;
46+ }
4147
42- //TODO: Check how can check after change structure
43- //countryInfo.Currencies
44- // .Should()
45- // .BeEquivalentTo(compareCountry.Currencies.ChildrenToke.Name.ToArray(),
46- // because: $"{countryCode} {string.Join(",", compareCountry.Currencies.Keys)} {string.Join(",", countryInfo.Currencies)}");
48+ //TODO: Check how can check after change structure
49+ //countryInfo.Currencies
50+ // .Should()
51+ // .BeEquivalentTo(compareCountry.Currencies.ChildrenToke.Name.ToArray(),
52+ // because: $"{countryCode} {string.Join(",", compareCountry.Currencies.Keys)} {string.Join(",", countryInfo.Currencies)}");
4753
48- Assert . AreEqual ( compareCountry . Ccn3 , countryInfo . NumericCode , $ "wrong numeric code by { countryCode } { countryInfo . CommonName } ") ;
49- Assert . AreEqual ( compareCountry . Region , countryInfo . Region . ToString ( ) , $ "wrong region by { countryCode } { countryInfo . CommonName } ") ;
50- //Assert.AreEqual(this.AdaptMledozeSubRegion(compareCountry.Subregion), this.GetSubRegion(countryInfo.SubRegion), $"wrong subregion by {countryCode} {countryInfo.CommonName}");
51- Assert . AreEqual ( compareCountry . Cca3 , countryInfo . Alpha3Code . ToString ( ) , $ "wrong alpha 3 code by { countryCode } { countryInfo . CommonName } ") ;
52- Assert . AreEqual ( compareCountry . Name . Common , countryInfo . CommonName . ToString ( ) , $ "wrong common name by { countryCode } { countryInfo . CommonName } ") ;
53- }
54+ Assert . AreEqual ( compareCountry . Ccn3 , countryInfo . NumericCode , $ "wrong numeric code by { countryCode } { countryInfo . CommonName } ") ;
55+ Assert . AreEqual ( compareCountry . Region , countryInfo . Region . ToString ( ) , $ "wrong region by { countryCode } { countryInfo . CommonName } ") ;
56+ //Assert.AreEqual(this.AdaptMledozeSubRegion(compareCountry.Subregion), this.GetSubRegion(countryInfo.SubRegion), $"wrong subregion by {countryCode} {countryInfo.CommonName}");
57+ Assert . AreEqual ( compareCountry . Cca3 , countryInfo . Alpha3Code . ToString ( ) , $ "wrong alpha 3 code by { countryCode } { countryInfo . CommonName } ") ;
58+ Assert . AreEqual ( compareCountry . Name . Common , countryInfo . CommonName . ToString ( ) , $ "wrong common name by { countryCode } { countryInfo . CommonName } ") ;
5459 }
5560 }
5661
0 commit comments