/// <summary> /// Taking to as destionation currency ///And calling GetConversionRate on currenct object and destination currency /// </summary> /// <param name="to"></param> /// <returns></returns> public Money Convert(string to) { //Checking for null arguements and white spaces and the length of arguement. if (string.IsNullOrWhiteSpace(to) || string.IsNullOrEmpty(to) || to.Length != 3 || Regex.IsMatch(to, @"^[a-zA-Z]+$") == false) { throw new ArgumentException(Messages.InvalidInput); } CurrencyConverter currencyConverter = new CurrencyConverter(); return new Money(Amount * currencyConverter.GetConversionRate(Currency, to), to); }
public void TestMethod16() { CurrencyConverter convert = new CurrencyConverter("ABCD"); convert.GetConversionRate("", ""); }
public Money Convert(string convertTo) { if(string.IsNullOrWhiteSpace(convertTo) || convertTo.Length != 3 || Regex.IsMatch(convertTo, @"^[a-zA-Z]+$")==false) throw new SystemException(Messages.CurrencyInvalid); CurrencyConverter converter = new CurrencyConverter(); return new Money(this.Amount * converter.GetConversionRate(this.Currency, convertTo), convertTo); }
public void TestMethod14() { CurrencyConverter convert = new CurrencyConverter(""); convert.GetConversionRate("INR", "USD"); }
public Money ConvertCurrency(string target) { if (Regex.IsMatch(target, @"^[a-zA-Z]+$") == false) { throw new Exception(Messages.TargetCurrency); } CurrencyConverter convertedCurrency = new CurrencyConverter(); double rate = convertedCurrency.GetConversionRate(this.Currency, target); var totalMoney = this.Amount * rate; return new Money(totalMoney, target); }