Ejemplo n.º 1
0
        public void FormatUsingDefaults()
        {
            NumberFormatter fmt = new NumberFormatter("en-US");
            Assert.AreEqual("1,234.00", fmt.Format(1234));
            Assert.AreEqual("1,234.56", fmt.Format(1234.56));
            Assert.AreEqual("-1,234.00", fmt.Format(-1234));
            Assert.AreEqual("-1,234.56", fmt.Format(-1234.56));

            fmt = new NumberFormatter("sr-SP-Latn");
            Assert.AreEqual("1.234,00", fmt.Format(1234));
            Assert.AreEqual("1.234,56", fmt.Format(1234.56));
            Assert.AreEqual("-1.234,00", fmt.Format(-1234));
            Assert.AreEqual("-1.234,56", fmt.Format(-1234.56));
        }
Ejemplo n.º 2
0
        public void FormatUsingDefaults()
        {
            NumberFormatter fmt = new NumberFormatter("en-US");

            Assert.AreEqual("1,234.00", fmt.Format(1234));
            Assert.AreEqual("1,234.56", fmt.Format(1234.56));
            Assert.AreEqual("-1,234.00", fmt.Format(-1234));
            Assert.AreEqual("-1,234.56", fmt.Format(-1234.56));

            fmt = new NumberFormatter("sr-SP-Latn");
            Assert.AreEqual("1.234,00", fmt.Format(1234));
            Assert.AreEqual("1.234,56", fmt.Format(1234.56));
            Assert.AreEqual("-1.234,00", fmt.Format(-1234));
            Assert.AreEqual("-1.234,56", fmt.Format(-1234.56));
        }
Ejemplo n.º 3
0
        public void FormatUsingCustomSettings()
        {
            NumberFormatter fmt = new NumberFormatter("en-US");

            fmt.DecimalDigits   = 0;
            fmt.NegativePattern = 0;
            Assert.AreEqual("1,234", fmt.Format(1234));
            Assert.AreEqual("1,235", fmt.Format(1234.56));
            Assert.AreEqual("(1,234)", fmt.Format(-1234));
            Assert.AreEqual("(1,235)", fmt.Format(-1234.56));

            fmt                = new NumberFormatter("sr-SP-Cyrl");
            fmt.GroupSizes     = new int[] { 1, 2 };
            fmt.GroupSeparator = "'";
            Assert.AreEqual("1'23'4,00", fmt.Format(1234));
            Assert.AreEqual("1'23'4,56", fmt.Format(1234.56));
            Assert.AreEqual("-1'23'4,00", fmt.Format(-1234));
            Assert.AreEqual("-1'23'4,56", fmt.Format(-1234.56));
        }
Ejemplo n.º 4
0
        public void FormatUsingCustomSettings()
        {
            NumberFormatter fmt = new NumberFormatter("en-US");
            fmt.DecimalDigits = 0;
            fmt.NegativePattern = 0;
            Assert.AreEqual("1,234", fmt.Format(1234));
            Assert.AreEqual("1,235", fmt.Format(1234.56));
            Assert.AreEqual("(1,234)", fmt.Format(-1234));
            Assert.AreEqual("(1,235)", fmt.Format(-1234.56));

            fmt = new NumberFormatter("sr-SP-Cyrl");
            fmt.GroupSizes = new int[] {1, 2};
            fmt.GroupSeparator = "'";
            Assert.AreEqual("1'23'4,00", fmt.Format(1234));
            Assert.AreEqual("1'23'4,56", fmt.Format(1234.56));
            Assert.AreEqual("-1'23'4,00", fmt.Format(-1234));
            Assert.AreEqual("-1'23'4,56", fmt.Format(-1234.56));
        }
Ejemplo n.º 5
0
 public void FormatNonNumber()
 {
     NumberFormatter fmt = new NumberFormatter();
     fmt.Format("not a number");
 }
Ejemplo n.º 6
0
 public void FormatNullValue()
 {
     NumberFormatter fmt = new NumberFormatter();
     fmt.Format(null);
 }
Ejemplo n.º 7
0
        public void FormatNonNumber()
        {
            NumberFormatter fmt = new NumberFormatter();

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

            Assert.Throws <ArgumentNullException>(() => fmt.Format(null));
        }
Ejemplo n.º 9
0
        public void FormatNonNumber()
        {
            NumberFormatter fmt = new NumberFormatter();

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

            fmt.Format(null);
        }
 public void FormatNonNumber()
 {
     NumberFormatter fmt = new NumberFormatter();
     Assert.Throws<ArgumentException>(() => fmt.Format("not a number"));
 }
 public void FormatNullValue()
 {
     NumberFormatter fmt = new NumberFormatter();
     Assert.Throws<ArgumentNullException>(() => fmt.Format(null));
 }