Example #1
0
File: Iso4217.cs Project: haf/Money
 /// <summary>
 /// Return currency from number code
 /// </summary>
 /// <param name="numCode">
 /// number code
 /// </param>
 /// <param name="currency">
 /// currency
 /// </param>
 /// <returns>
 /// true if ISO 4217 contain this currency
 /// </returns>
 public static bool TryParse(int numCode, out ICurrency currency)
 {
     currency = Parse(numCode);
     if(currency != null)
         return true;
     currency = new UnknownCurrency(numCode);
     return false;
 }
Example #2
0
File: Iso4217.cs Project: haf/Money
 /// <summary>
 /// Return currency from character code
 /// </summary>
 /// <param name="charCode">
 /// character code
 /// </param>
 /// <param name="currency">
 /// currency
 /// </param>
 /// <returns>
 /// true if ISO 4217 contain this currency
 /// </returns>
 public static bool TryParse(string charCode, out ICurrency currency)
 {
     currency = Parse(charCode);
     if(currency != null)
         return true;
     currency = new UnknownCurrency(charCode);
     return false;
 }
Example #3
0
        public void Equals()
        {
            ICurrency c1 = Iso4217.RUB;
            ICurrency c2 = Iso4217.AED;
            Assert.AreNotEqual(c1, c2);
            Assert.IsFalse(c1 == c2);

            ICurrency c3 = Iso4217.RUB;
            Assert.AreEqual(c1, c3);
            Assert.IsTrue(c1 == c3);

            UnknownCurrency uc = new UnknownCurrency("RUB");
            Assert.AreNotEqual(c1, uc);
            Assert.IsFalse(c1 == uc);
        }