public void ParseUsingDefaults()
        {
            IntegerFormatter fmt = new IntegerFormatter();

            Assert.AreEqual(1234, fmt.Parse("1234"));
            Assert.AreEqual(-1234, fmt.Parse("-1234"));
        }
        public void FormatUsingDefaults()
        {
            IntegerFormatter fmt = new IntegerFormatter();

            Assert.AreEqual("1234", fmt.Format(1234));
            Assert.AreEqual("-1234", fmt.Format(-1234));
        }
        public void ParseNullOrEmptyValue()
        {
            IntegerFormatter fmt = new IntegerFormatter();

            Assert.AreEqual(0, fmt.Parse(null));
            Assert.AreEqual(0, fmt.Parse(string.Empty));
        }
        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));
        }
        public void FormatNonNumber()
        {
            IntegerFormatter fmt = new IntegerFormatter();

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

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