static void Main(string[] args) { try { Console.WriteLine("Format : 100 USD"); Console.WriteLine("\nEnter Amount : "); // Enter Amount in Format '100 USD' var m1 = new Money(Console.ReadLine()); Console.WriteLine("\nEnter target Currency : "); // Enter target currency var m2 = new Money(0, Console.ReadLine()); var exchangedRate = m1.Convert(m2.Currency); Console.WriteLine("\nExchanged Amount : {0} {1} ", exchangedRate.Amount, exchangedRate.Currency); } catch (ArgumentException a) { Console.WriteLine(a.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadKey(); }
public void TestMethod1() { var money = new Money(100, "USD"); var amount = money.Convert("INR"); Assert.IsTrue(amount == 6347.345); }
static void Main(string[] args) { try { Console.WriteLine("Enter the amount and the Curreny type,, ex: 100 USD "); //Calling the Parameterized constructor of Money Class var moneyOne = new Money(Console.ReadLine()); Console.WriteLine("Enter the amount and the Curreny type,, ex: 100 USD"); //Calling the Parameterized constructor of Money Class. var moneyTwo = new Money(Console.ReadLine()); //Overloading the Plus operator. Console.WriteLine(moneyTwo + moneyOne); Console.WriteLine("Enter the amount and Currency type ex: 100 USD"); var money = new Money(Console.ReadLine()); Console.WriteLine("Enter the currency you want to convert into ex :INR "); var convertedMoney = money.Convert(Console.ReadLine()); Console.WriteLine(convertedMoney); Console.ReadKey(); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); } }
static void Main(string[] args) { Money money1 = new Money(); while (true)// condition to check currency is not empty { Console.WriteLine("Enter 1st Currency."); try { money1.Currency = Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.Message); continue; } break; } while (true) //this while keep on taking the input unless you enter valid amount. { Console.WriteLine("Enter amount for that Currency."); string input = Console.ReadLine(); double temp = 0.0; if (double.TryParse(input, out temp)) { money1.Amount = temp; break; } else { Console.WriteLine("Invalid Amount, Enter again: "); continue; } } Console.WriteLine("Enter currency to which you want to convert: "); string toCurrency = Console.ReadLine(); Money money2 = new Money(); try { money2 = money1.Convert(toCurrency); } catch (Exception e) { Console.WriteLine(e.Message); Console.ReadKey(); return; } Console.WriteLine(); Console.WriteLine("Converted Amount:"); Console.WriteLine(money2); Console.ReadKey(); }
static void Main(string[] args) { double money = 0.0; string sourceCurrency = null; try { Console.WriteLine("\nEnter Amount : "); while (double.TryParse(Console.ReadLine(), out money) == false) { Console.WriteLine(" Enter valid entry for money"); } Console.WriteLine("Enter Currency"); sourceCurrency = Console.ReadLine(); Money money1 = new Money(money,sourceCurrency); Console.WriteLine("\nEnter target Currency : "); string target = Console.ReadLine(); Console.WriteLine("\nExchanged Amount : "); var money2 = new Money(target); double exchangedRate = money1.Convert(money1.Amount, money1.Currency, money2.Currency); Console.WriteLine("{0} {1}", exchangedRate, target.ToUpper()); } catch (ArgumentException ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine(ex); } Console.ReadKey(); }
public static void Main(string[] args) { try { //Adding comment for changes. Making changes in this comment //Console.Write("Enter Amount 1 (<Amt> CType): "); //Money amount1 = new Money(Console.ReadLine()); //Console.Write("Enter Amount 2 (<Amt> CType): "); //Money amount2 = new Money(Console.ReadLine()); //Console.Write("The Total Amount is: "); //Console.WriteLine(amount1 + amount2); Console.Write("Enter Amount 3 (<Amt> CType): "); Money amount3 = new Money(Console.ReadLine()); Console.Write("Enter Currency to Convert to: "); string convertTo = Console.ReadLine(); Money convertedAmount = amount3.Convert(convertTo); Console.WriteLine("The Converted Amount is: " + convertedAmount); } catch (Exception e) { Console.WriteLine("Exception Occured."); Console.WriteLine(e.Message); } Console.ReadLine(); }
public void InvalidLengthSourceCurrency() { var money1 = new Money("100 UD"); var money2 = money1.Convert("INR"); var money3 = new Money("100 USDF"); var money4 = money3.Convert("INR"); }
public void ValidTest() { var money1 = new Money("100 USD"); var money2 = money1.Convert("INR"); //MOQ can be used for same purpose string filePath = ConfigurationManager.AppSettings["Path"]; string json = System.IO.File.ReadAllText(filePath); int indexSource = json.IndexOf("USDINR"); int indexStart = json.IndexOf(':', indexSource) + 1; int indexEnd = json.IndexOf(',', indexStart); string value = json.Substring(indexStart, indexEnd - indexStart); double checkValue; double.TryParse(value, out checkValue); Assert.IsTrue(money2.Amount == checkValue * money1.Amount); }
public static void Main(string[] args) { try { Console.WriteLine("Enter the amount in the form of <100 USD>"); var amount = new Money(Console.ReadLine()); Console.WriteLine("Enter the currency in which you want to convert"); string toCurrency = Console.ReadLine(); var output = amount.Convert(toCurrency.ToUpper()); Console.WriteLine("your Converted amount is " + output); Console.ReadKey(); } catch (Exception e) { Console.WriteLine("OOPS..!! There occur some error"); Console.WriteLine(e.Message); Console.ReadKey(); } }
public static void Main(string[] args) { try { Console.Write("Enter first Amount (Amount Currency) "); var Money1 = new Money(Console.ReadLine()); Console.WriteLine("Enter the Amount to Convert "); string toCurrency = Console.ReadLine(); var output = Money1.Convert(toCurrency); Console.WriteLine("Your Converted amount is " + output); Console.ReadKey(); } catch (Exception e) { Console.WriteLine("Exception Occured."); Console.WriteLine(e.Message); } Console.ReadLine(); }
static void Main(string[] args) { try { Console.WriteLine("Performing Currency Conversion"); Console.WriteLine("Enter Amount to be converted and Source Currency"); var moneyOne = new Money(Console.ReadLine());//in format "100 USD" Console.WriteLine("Enter Target Currency"); string targetCurrency = Console.ReadLine();//in format "INR" var getexchangeRates1 = moneyOne.Convert(targetCurrency); Console.WriteLine("Converted Amount in " + targetCurrency + "= " + moneyOne.Amount + " " + targetCurrency); } catch (Exception e) { Console.WriteLine(e.Message); } Console.ReadKey(); }
public void CurrencyNotFound() { var money1 = new Money("100 USD"); var money2 = money1.Convert("YEN"); }
public void TestMethod5() { var money = new Money(100, "USD"); var amount = money.Convert("\0"); }
public void TestMethod10() { var money = new Money(100, "YEN"); var amount = money.Convert("INR"); }
public void CurrencyToConvertInvalid() { var money1 = new Money("100 USD"); var money2 = money1.Convert("100"); }
public void CurrencyToConvertNull() { var money1 = new Money("100 USD"); var money2 = money1.Convert(null); }
public void SourceNull() { var money1 = new Money(null); var money2 = money1.Convert("INR"); }