예제 #1
0
        public void FormatUsingDefaults()
        {
            FloatFormatter fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "en-US");
            Assert.AreEqual("1234.00", fmt.Format(1234));
            Assert.AreEqual("-1234.00", fmt.Format(-1234));

            fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "sr-SP-Latn");
            Assert.AreEqual("1234,00", fmt.Format(1234));
            Assert.AreEqual("-1234,00", fmt.Format(-1234));
        }
예제 #2
0
        public void FormatUsingDefaults()
        {
            FloatFormatter fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "en-US");

            Assert.AreEqual("1234.00", fmt.Format(1234));
            Assert.AreEqual("-1234.00", fmt.Format(-1234));

            fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "sr-SP-Latn");
            Assert.AreEqual("1234,00", fmt.Format(1234));
            Assert.AreEqual("-1234,00", fmt.Format(-1234));
        }
예제 #3
0
        public void ParseUsingDefaults()
        {
            FloatFormatter fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "en-US");
            Assert.AreEqual(1234.56, fmt.Parse("1234.56"));
            Assert.AreEqual(-1234, fmt.Parse("-1234"));
            Assert.AreEqual(1234.56, fmt.Parse("1.23456e+003"));
            Assert.AreEqual(-1234, fmt.Parse("-1.234e+003"));

            fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "sr-SP-Cyrl");
            Assert.AreEqual(1234.56, fmt.Parse("1234,56"));
            Assert.AreEqual(-1234, fmt.Parse("-1234"));
            Assert.AreEqual(1234.56, fmt.Parse("1,23456e+003"));
            Assert.AreEqual(-1234, fmt.Parse("-1,234e+003"));
        }
예제 #4
0
        public void ParseUsingDefaults()
        {
            FloatFormatter fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "en-US");

            Assert.AreEqual(1234.56, fmt.Parse("1234.56"));
            Assert.AreEqual(-1234, fmt.Parse("-1234"));
            Assert.AreEqual(1234.56, fmt.Parse("1.23456e+003"));
            Assert.AreEqual(-1234, fmt.Parse("-1.234e+003"));

            fmt = new FloatFormatter(FloatFormatter.DefaultFormat, "sr-SP-Cyrl");
            Assert.AreEqual(1234.56, fmt.Parse("1234,56"));
            Assert.AreEqual(-1234, fmt.Parse("-1234"));
            Assert.AreEqual(1234.56, fmt.Parse("1,23456e+003"));
            Assert.AreEqual(-1234, fmt.Parse("-1,234e+003"));
        }
예제 #5
0
 public void FormatUsingCustomSettings()
 {
     FloatFormatter fmt = new FloatFormatter("{0:e3}", "en-US");
     Assert.AreEqual("1.234e+003", fmt.Format(1234));
     Assert.AreEqual("-1.234e+003", fmt.Format(-1234));
     Assert.AreEqual("1.235e+003", fmt.Format(1234.56));
     Assert.AreEqual("-1.235e+003", fmt.Format(-1234.56));
 }
예제 #6
0
 public void FormatNonNumber()
 {
     FloatFormatter fmt = new FloatFormatter();
     fmt.Format("not a number");
 }
예제 #7
0
 public void ParseNullOrEmptyValue()
 {
     FloatFormatter fmt = new FloatFormatter();
     Assert.AreEqual(0, fmt.Parse(null));
     Assert.IsTrue(fmt.Parse("") is double);
 }
예제 #8
0
 public void FormatNullValue()
 {
     FloatFormatter fmt = new FloatFormatter();
     fmt.Format(null);
 }
 public void FormatNonNumber()
 {
     FloatFormatter fmt = new FloatFormatter();
     Assert.Throws<ArgumentException>(() => fmt.Format("not a number"));
 }
 public void FormatNullValue()
 {
     FloatFormatter fmt = new FloatFormatter();
     Assert.Throws<ArgumentNullException>(() => fmt.Format(null));
 }
예제 #11
0
        public void FormatNonNumber()
        {
            FloatFormatter fmt = new FloatFormatter();

            Assert.Throws <ArgumentException>(() => fmt.Format("not a number"));
        }
예제 #12
0
        public void FormatNullValue()
        {
            FloatFormatter fmt = new FloatFormatter();

            Assert.Throws <ArgumentNullException>(() => fmt.Format(null));
        }
예제 #13
0
        public void FormatNonNumber()
        {
            FloatFormatter fmt = new FloatFormatter();

            fmt.Format("not a number");
        }
예제 #14
0
        public void FormatNullValue()
        {
            FloatFormatter fmt = new FloatFormatter();

            fmt.Format(null);
        }