Пример #1
0
        public void ConvertsBackStringToDecimalValue()
        {
            StringToCurrencyConverter converter = new StringToCurrencyConverter();

            decimal result = (decimal)converter.ConvertBack(stringTestValue, null, null, CultureInfo.CurrentCulture);

            Assert.AreEqual(decimalTestValue, result, "Invalid back conversion from string to decimal.");
        }
Пример #2
0
        public void ConvertsBackAndIgnoresTrailingDecimalSeparator()
        {
            StringToCurrencyConverter converter = new StringToCurrencyConverter();

            string testString = "123" + sep;

            decimal result = (decimal)converter.ConvertBack(testString, null, null, CultureInfo.CurrentCulture);

            Assert.AreEqual(123.0m, result);
        }
Пример #3
0
        public void ConvertsBackAndTrimsRedundantDecimalPlaces()
        {
            StringToCurrencyConverter converter = new StringToCurrencyConverter();

            string testString = "123" + sep + "4567";

            decimal result = (decimal)converter.ConvertBack(testString, null, null, CultureInfo.CurrentCulture);

            Assert.AreEqual(123.45m, result);
        }
Пример #4
0
        public void ConvertsBackWithTrailingDecimalSeparatorAndAddsZero()
        {
            StringToCurrencyConverter converter = new StringToCurrencyConverter();

            string testString = "123" + sep;

            decimal result    = (decimal)converter.ConvertBack(testString, null, null, CultureInfo.CurrentCulture);
            string  strResult = result.ToString();

            Assert.AreEqual("123" + sep + "0", strResult);
        }