// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; using NUnit.Framework; using E_NAnt; [TestFixture] public class SpecialFormatsTest { [SetUp] protected void Init() { } [TearDown] protected void Dispose() { } [Test] public void FormatDateTimeNormal() { Assert.AreEqual("13-Mar-2005 21:15", SpecialFormats.FormatDateTime(new DateTime(2005, 3, 13, 21, 15, 0)), "2 digit day"); Assert.AreEqual("03-Mar-2005 21:15", SpecialFormats.FormatDateTime(new DateTime(2005, 3, 3, 21, 15, 0)), "1 digit day"); } [Test] public void FormatDateTimeAbnormal() { Assert.AreEqual("13-Mar-1965 21:15", SpecialFormats.FormatDateTime(new DateTime(1965, 3, 13, 21, 15, 0)), "before 1970"); Assert.AreEqual("13-Mar-1865 21:15", SpecialFormats.FormatDateTime(new DateTime(1865, 3, 13, 21, 15, 0)), "before 1900"); } [Test] public void FormatMoneyVarious() { Assert.AreEqual("123.45 kroner", SpecialFormats.FormatMoney(123.45m), "standard"); Assert.AreEqual("123.00 kroner", SpecialFormats.FormatMoney(123m), "no decimals"); Assert.AreEqual("0.45 kroner", SpecialFormats.FormatMoney(0.45m), "only decimals"); Assert.AreEqual("1234567890.00 kroner", SpecialFormats.FormatMoney(1234567890m), "huge"); } }