コード例 #1
0
        public void Constructor_ValidCountryCodeValidRegionInfo_CorrectProperties(
            [ValueSource(nameof(ValidCountries))] KeyValuePair <string, string> countryCode)
        {
            var country     = new Iso3166Country(countryCode.Key);
            var countryName = Iso3166Helper.CountryCodeMappings[countryCode.Key];
            var regionInfo  = country.RegionInfo;

            var upperCountryCode = countryCode.Key.ToUpperInvariant();

            Assert.That(country.CountryCode, Is.EqualTo(upperCountryCode));
            Assert.That(
                country.CountryName,
                Is.EqualTo(countryCode.Value).And.EqualTo(countryName));
            Assert.That(regionInfo, Is.Not.Null);
            Assert.That(regionInfo.TwoLetterISORegionName, Is.EqualTo(upperCountryCode));
        }
コード例 #2
0
        public void Constructor_ValidCountryCodeInvalidRegionInfo_ArgumentException(
            [ValueSource(nameof(ValidCountriesNoRegion))] KeyValuePair <string, string> countryCode)
        {
            var country     = new Iso3166Country(countryCode.Key);
            var countryName = Iso3166Helper.CountryCodeMappings[countryCode.Key];
            var ex          = Assert.Throws <ArgumentException>(
                () => { var regionInfo = country.RegionInfo; });

            var upperCountryCode = countryCode.Key.ToUpperInvariant();

            Assert.That(country.CountryCode, Is.EqualTo(upperCountryCode));
            Assert.That(
                country.CountryName,
                Is.EqualTo(countryCode.Value).And.EqualTo(countryName));
            Assert.That(ex.ParamName, Is.EqualTo(RegionInfoNameParam));
        }
コード例 #3
0
        public static ElectionEntity GetEmptyElectionEntity(Iso3166Country associatedCountry)
        {
            return(new ElectionEntity
            {
                Year = 0,
                CountryCode = associatedCountry.Alpha3,
                CountryName = associatedCountry.Name,

                PartyName = "None",
                PartyAbbreviation = "NA",
                PartyClassification = "unknown",
                PartyCandidates = new HashSet <string> {
                    "No candidates found"
                },

                TotalAmountOfVotes = 0,
                TotalVotePercentage = 0.0,
                TotalAmountOfSeatsGained = 0
            });
        }
コード例 #4
0
 public static DictatorshipEntity GetEmptyDictatorshipEntity(Iso3166Country associatedCountry)
 {
     return(new DictatorshipEntity {
         CountryCode = associatedCountry.Alpha3, Name = "Unknown", PartyClassification = "Unknown", From = 0000, To = 0000
     });
 }