예제 #1
0
 public void GetGdCountry(string code, uint callingCode, string expectedCurrency)
 {
     Base.Country.Country country = CountryList.Get(CountryIso2Code.FromString(code));
     Output.WriteLine($"Expected currency: {expectedCurrency}, output: {country.Currency.Code}");
     Assert.Equal(callingCode, country.CallingCode);
     Assert.Equal(expectedCurrency, country.Currency.Code);
 }
예제 #2
0
        public void ParseCountryIso2CodeTest(string code)
        {
            CountryIso2Code countryCode = CountryIso2Code.FromString(code);

            Output.WriteLine($"Expected: {code.ToUpper()} , output: {countryCode.Code}");
            Assert.Equal(code.ToUpper(), countryCode.Code);
        }
예제 #3
0
        /// <summary>
        /// Get a GdCountry by Iso2 Code.
        /// </summary>
        /// <param name="countryCode"></param>
        /// <returns>Instance of GdCountry</returns>
        public static Country Get(CountryIso2Code countryCode)
        {
            if (GdCountryDict.TryGetValue(countryCode.Code, out Country value))
            {
                return(value);
            }

            throw new InvalidCountryCodeException(countryCode.Code);
        }
예제 #4
0
 public Country(string name, string namePrefix, string namePostfix, string codeIso2, string codeIso3, string currencyCode, uint callingCode, uint[] callingCodes)
 {
     Name         = name;
     NameAllCaps  = name.ToUpper();
     NamePrefix   = namePrefix;
     NamePostfix  = namePostfix;
     CodeIso2     = CountryIso2Code.FromString(codeIso2);
     CodeIso3     = GdCountryIso3Code.FromString(codeIso3);
     Currency     = CurrencyFiatCode.FromString(currencyCode);
     CallingCode  = callingCode;
     CallingCodes = callingCodes;
 }
예제 #5
0
        private BicCode(string code)
        {
            code = code.ToUpper();
            if (code.Length != CODE_LENGTH && code.Length != CODE_LENGTH_WITH_BRANCH)
            {
                throw new InvalidPrimaryBicCode(code);
            }

            // Skip Branch code
            Code = code.Substring(0, CODE_LENGTH);

            // Set country code
            CountryCode = CountryIso2Code.FromString(code.Substring(4, 2));

            // Unique bank code within the country above
            BankCode = code.Substring(0, 4);
        }
예제 #6
0
 public void ParseCountryIso2CodeFailTest()
 {
     Assert.Throws <InvalidCountryCodeException>(() => CountryIso2Code.FromString("ZZ"));
 }