public void CanUseCustomFormatterWithStringFormatMethod()
        {
            PersonFormatter fmt = new PersonFormatter();

            fmt.OutputName = true;

            Person p = new Person("Christian Crowhurst", DateTime.Parse("1974-06-25 08:00:00"));

            Assert.AreEqual("Christian Crowhurst", string.Format(fmt, "{0}", p), "Name of person only ouput");
        }
        public void CanFormatBothPersonAndPrimitiveTypes()
        {
            PersonFormatter fmt = new PersonFormatter();

            fmt.OutputName = true;

            Person p        = new Person("Christian Crowhurst", DateTime.Parse("1974-06-25 08:00:00"));
            string actual   = string.Format(fmt, "{0} as output on {1}", p, DateTime.Now);
            string expected = string.Format("Christian Crowhurst as output on {0}", DateTime.Now);

            Assert.AreEqual(expected, actual, "both types output correctly");
        }
        public void CanUseCustomFormatterWithStringBuilder()
        {
            PersonFormatter fmt = new PersonFormatter();

            fmt.OutputName = true;

            Person        p  = new Person("Christian Crowhurst", DateTime.Parse("1974-06-25 08:00:00"));
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(fmt, "{0}", p);
            Assert.AreEqual("Christian Crowhurst", sb.ToString(), "Name of person only ouput");
        }