コード例 #1
0
        public void ConversionBreadth()
        {
            decimal      result;
            decimal      amount;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            amount  = 100.0M;
            fromCur = new PENCurrency();
            toCur   = new PENCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, ".....");
        }
コード例 #2
0
        private void ConvertButton_Click(object sender, System.EventArgs e)
        {
            decimal      converted = 0.0M;
            decimal      initial   = 0.0M;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            initial     = Convert.ToDecimal(Amount.Text);
            fromCur     = fromCombo.SelectedItem as BaseCurrency;
            toCur       = toCombo.SelectedItem as BaseCurrency;
            converted   = ConvertibleCurrency.CurrencyConvert(initial, fromCur, toCur);
            Result.Text = converted.ToString();
        }
コード例 #3
0
        private void ConvertButton_Click(object sender, EventArgs e)
        {
            decimal      converted = 0.0M;
            decimal      initial   = 0.0M;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            initial   = Convert.ToDecimal(Amount.Text);
            fromCur   = fromCombo.SelectedItem as BaseCurrency;
            toCur     = toCombo.SelectedItem as BaseCurrency;
            converted = ConvertibleCurrency.CurrencyConvert(initial, fromCur, toCur);
            //Result.Text = converted.ToString();
            //Result.Text = String.Format("{0:c3}", converted);
            Result.Text = String.Format("{0:f3}", Decimal.ToDouble(converted));
        }
コード例 #4
0
        public void ConversionBreadth()
        {
            decimal      result;
            decimal      amount;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            amount  = 100.0M;
            fromCur = new USCurrency();
            toCur   = new USCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "US to US should be no change");

            fromCur = new UKCurrency();
            toCur   = new UKCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "UK to UK should be no change");

            fromCur = new AUSCurrency();
            toCur   = new AUSCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "AUS to AUS should be no change");

            decimal expected;

            fromCur  = new USCurrency();
            toCur    = new AUSCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount * 2;
            Assert.AreEqual(expected, result, "US to AUS is incorrect");

            fromCur  = new UKCurrency();
            toCur    = new AUSCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount / 0.5M * 2;
            Assert.AreEqual(expected, result,
                            "UK to AUS is incorrect");
        }
コード例 #5
0
ファイル: ConvertTest.cs プロジェクト: luisporrascc/current
        public void ConversionBreadth()
        {
            decimal      result;
            decimal      amount;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            amount  = 100.0M;
            fromCur = new USDCurrency();
            toCur   = new USDCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "USD to USD should be no change");

            fromCur = new PENCurrency();
            toCur   = new PENCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "PEN to PEN should be no change");

            fromCur = new EURCurrency();
            toCur   = new EURCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "EUR to EUR should be no change");

            decimal expected;

            fromCur  = new USDCurrency();
            toCur    = new EURCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount * 0.85M;
            Assert.AreEqual(expected, result, "USD to EUR is incorrect");

            fromCur  = new PENCurrency();
            toCur    = new EURCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount / 3.53M * 0.85M;
            Assert.AreEqual(expected, result, "PEN to EUR is incorrect");
        }
コード例 #6
0
        public void ConversionBreadth()
        {
            decimal      result;
            decimal      amount;
            BaseCurrency fromCur;
            BaseCurrency toCur;

            amount  = 100.0M;
            fromCur = new UsdCurrency();
            toCur   = new UsdCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "USD to USD NO CAMBIA");

            fromCur = new PenCurrency();
            toCur   = new PenCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "PEN to PEN NO CAMBIA");

            fromCur = new EurCurrency();
            toCur   = new EurCurrency();
            result  = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            Assert.AreEqual(100.0M, result, "EUR to EUR NO CAMBIA");
            decimal expected;

            fromCur  = new UsdCurrency();
            toCur    = new EurCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount * (decimal)0.85;
            Assert.AreEqual(expected, result, "US to AUS is incorrect");

            fromCur  = new PenCurrency();
            toCur    = new EurCurrency();
            result   = ConvertibleCurrency.CurrencyConvert(amount, fromCur, toCur);
            expected = amount * (decimal)4.16;
            Assert.AreEqual(expected, result, "PEN to EUR es incorrecto");
        }