Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }
Пример #5
0
 public void FormatNonNumber()
 {
     NumberFormatter fmt = new NumberFormatter();
     fmt.Format("not a number");
 }
Пример #6
0
 public void FormatNullValue()
 {
     NumberFormatter fmt = new NumberFormatter();
     fmt.Format(null);
 }
Пример #7
0
        public void FormatNonNumber()
        {
            NumberFormatter fmt = new NumberFormatter();

            Assert.Throws <ArgumentException>(() => fmt.Format("not a number"));
        }
Пример #8
0
        public void FormatNullValue()
        {
            NumberFormatter fmt = new NumberFormatter();

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

            fmt.Format("not a number");
        }
Пример #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));
 }