Ejemplo n.º 1
0
        public void ParseNullOrEmptyValue()
        {
            PercentFormatter fmt = new PercentFormatter();

            Assert.AreEqual(0, fmt.Parse(null));
            Assert.IsTrue(fmt.Parse("") is double);
        }
Ejemplo n.º 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%"));
        }
Ejemplo n.º 3
0
        public void FormatUsingDefaults()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");
            Assert.AreEqual("25.00 %", fmt.Format(0.25));
            Assert.AreEqual("25.34 %", fmt.Format(0.2534));

            fmt = new PercentFormatter("sr-SP-Latn");
            Assert.AreEqual("25,00%", fmt.Format(0.25));
            Assert.AreEqual("25,34%", fmt.Format(0.2534));
        }
Ejemplo n.º 4
0
        public void FormatUsingDefaults()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");

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

            fmt = new PercentFormatter("sr-SP-Latn");
            Assert.AreEqual("25,00%", fmt.Format(0.25));
            Assert.AreEqual("25,34%", fmt.Format(0.2534));
        }
Ejemplo n.º 5
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%"));
        }
Ejemplo n.º 6
0
        public void FormatUsingCustomSettings()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");
            fmt.DecimalDigits = 0;
            fmt.PositivePattern = 1;
            Assert.AreEqual("25%", fmt.Format(0.25));
            Assert.AreEqual("25%", fmt.Format(0.2534));

            fmt = new PercentFormatter("sr-SP-Latn");
            fmt.DecimalDigits = 1;
            Assert.AreEqual("25,0%", fmt.Format(0.25));
            Assert.AreEqual("25,3%", fmt.Format(0.2534));
        }
Ejemplo n.º 7
0
        public void FormatUsingCustomSettings()
        {
            PercentFormatter fmt = new PercentFormatter("en-US");

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

            fmt = new PercentFormatter("sr-SP-Latn");
            fmt.DecimalDigits = 1;
            Assert.AreEqual("25,0%", fmt.Format(0.25));
            Assert.AreEqual("25,3%", fmt.Format(0.2534));
        }
Ejemplo n.º 8
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%"));
        }
Ejemplo n.º 9
0
 public void FormatNonNumber()
 {
     PercentFormatter fmt = new PercentFormatter();
     fmt.Format("not a number");
 }
Ejemplo n.º 10
0
 public void ParseNullOrEmptyValue()
 {
     PercentFormatter fmt = new PercentFormatter();
     Assert.AreEqual(0, fmt.Parse(null));
     Assert.IsTrue(fmt.Parse("") is double);
 }
Ejemplo n.º 11
0
 public void FormatNullValue()
 {
     PercentFormatter fmt = new PercentFormatter();
     fmt.Format(null);
 }
Ejemplo n.º 12
0
        public void FormatNonNumber()
        {
            PercentFormatter fmt = new PercentFormatter();

            Assert.Throws <ArgumentException>(() => fmt.Format("not a number"));
        }
Ejemplo n.º 13
0
        public void FormatNonNumber()
        {
            PercentFormatter fmt = new PercentFormatter();

            fmt.Format("not a number");
        }
Ejemplo n.º 14
0
        public void FormatNullValue()
        {
            PercentFormatter fmt = new PercentFormatter();

            fmt.Format(null);
        }
 public void FormatNonNumber()
 {
     PercentFormatter fmt = new PercentFormatter();
     Assert.Throws<ArgumentException>(() => fmt.Format("not a number"));
 }
 public void FormatNullValue()
 {
     PercentFormatter fmt = new PercentFormatter();
     Assert.Throws<ArgumentNullException>(() => fmt.Format(null));
 }
Ejemplo n.º 17
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%"));
        }
Ejemplo n.º 18
0
        public void FormatNullValue()
        {
            PercentFormatter fmt = new PercentFormatter();

            Assert.Throws <ArgumentNullException>(() => fmt.Format(null));
        }