|
| 1 | +namespace World.Net.UnitTests.Countries; |
| 2 | + |
| 3 | +public sealed class ChinaTest |
| 4 | +{ |
| 5 | + private const string CHINA_COUNTRY_NAME = "China"; |
| 6 | + private const string CHINA_NATIVE_NAME = "中国"; |
| 7 | + private const string CHINA_CAPITAL = "Beijing"; |
| 8 | + private const string CHINA_OFFICIAL_NAME = "People's Republic of China"; |
| 9 | + private const string CHINA_ISO2_CODE = "CN"; |
| 10 | + private const string CHINA_ISO3_CODE = "CHN"; |
| 11 | + private const int CHINA_NUMERIC_CODE = 156; |
| 12 | + private const string CHINA_CALLING_CODE = "+86"; |
| 13 | + private const int CHINA_STATE_COUNT = 34; // 23 Provinces, 4 Municipalities, 5 Autonomous Regions, 2 SAR |
| 14 | + private static readonly string[] VALID_STATE_TYPES = { "Province", "Municipality", "Autonomous Region", "Special Administrative Region" }; |
| 15 | + |
| 16 | + [Fact] |
| 17 | + public void GetCountry_ReturnsCorrectInformation_ForChina() |
| 18 | + { |
| 19 | + // Arrange |
| 20 | + CountryIdentifier existingCountryId = CountryIdentifier.China; |
| 21 | + |
| 22 | + // Act |
| 23 | + var country = CountryProvider.GetCountry(existingCountryId); |
| 24 | + |
| 25 | + // Assert |
| 26 | + Assert.NotNull(country); |
| 27 | + Assert.Equal(existingCountryId, country.Id); |
| 28 | + Assert.Equal(CHINA_COUNTRY_NAME, country.Name); |
| 29 | + Assert.Equal(CHINA_OFFICIAL_NAME, country.OfficialName); |
| 30 | + Assert.Equal(CHINA_NATIVE_NAME, country.NativeName); |
| 31 | + Assert.Equal(CHINA_CAPITAL, country.Capital); |
| 32 | + Assert.Equal(CHINA_NUMERIC_CODE, country.NumericCode); |
| 33 | + Assert.Equal(CHINA_ISO2_CODE, country.ISO2Code); |
| 34 | + Assert.Equal(CHINA_ISO3_CODE, country.ISO3Code); |
| 35 | + Assert.Equal(CHINA_CALLING_CODE, country.CallingCode); |
| 36 | + Assert.NotNull(country.States); |
| 37 | + Assert.Equal(CHINA_STATE_COUNT, country.States.Count()); |
| 38 | + |
| 39 | + // Assert that each state has a valid type |
| 40 | + Assert.All(country.States, state => Assert.Contains(state.Type, VALID_STATE_TYPES)); |
| 41 | + } |
| 42 | +} |
0 commit comments