コード例 #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);
        }