Exemple #1
0
        public void ParseNullOrEmptyValue()
        {
            PercentFormatter fmt = new PercentFormatter();

            Assert.AreEqual(0, fmt.Parse(null));
            Assert.IsTrue(fmt.Parse("") is double);
        }
Exemple #2
0
        public void ParseUsingDefaults()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");

            Assert.AreEqual(0.25, fmt.Parse("25.00 %"));
            Assert.AreEqual(0.2534, fmt.Parse("25.34 %"));

            fmt = new PercentFormatter("sr-SP-Latn");
            Assert.AreEqual(0.25, fmt.Parse("25,00%"));
            Assert.AreEqual(0.2534, fmt.Parse("25,34%"));
        }
Exemple #3
0
        public void ParseUsingCustomSettings()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");

            fmt.DecimalDigits   = 0;
            fmt.PositivePattern = 1;
            Assert.AreEqual(0.25, fmt.Parse("25%"));
            Assert.AreEqual(0.2534, fmt.Parse("25.34%"));

            fmt = new PercentFormatter("sr-SP-Latn");
            fmt.DecimalDigits = 1;
            Assert.AreEqual(0.25, fmt.Parse("25,0%"));
            Assert.AreEqual(0.253, fmt.Parse("25,3%"));
        }