Exemplo n.º 1
0
        public void FormatUsingDefaults()
        {
            IntegerFormatter fmt = new IntegerFormatter();

            Assert.AreEqual("1234", fmt.Format(1234));
            Assert.AreEqual("-1234", fmt.Format(-1234));
        }
Exemplo n.º 2
0
        public void FormatUsingCustomSettings()
        {
            IntegerFormatter fmt = new IntegerFormatter("{0:00000}");

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

            fmt = new IntegerFormatter("{0,10}");
            Assert.AreEqual("      1234", fmt.Format(1234));

            fmt = new IntegerFormatter("{0,-10}");
            Assert.AreEqual("1234      ", fmt.Format(1234));

            fmt = new IntegerFormatter("{0:(###) ###-####}");
            Assert.AreEqual("(813) 555-4034", fmt.Format(8135554034));
        }
Exemplo n.º 3
0
        public void FormatNonNumber()
        {
            IntegerFormatter fmt = new IntegerFormatter();

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

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