예제 #1
0
        public void FormatUsingDefaults()
        {
            IntegerFormatter fmt = new IntegerFormatter();

            Assert.AreEqual("1234", fmt.Format(1234));
            Assert.AreEqual("-1234", fmt.Format(-1234));
        }
예제 #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));
        }
예제 #3
0
        public void FormatNonNumber()
        {
            IntegerFormatter fmt = new IntegerFormatter();

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

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