public void DecodeTest() { string birthday = "19700731"; IDateParser dateParser = new DateParser(); DateTime? bDay = dateParser.Decode(birthday); Assert.IsNotNull(bDay); Assert.AreEqual(31, bDay.Value.Day); Assert.AreEqual(1970, bDay.Value.Year); Assert.AreEqual(07, bDay.Value.Month); string wrong = "1970X031"; DateTime?wrongDay = dateParser.Decode(wrong); Assert.IsNull(wrongDay); }
public void DecodeTest1() { decimal birthday = 19700731.0m; IDateParser dateParser = new DateParser(); DateTime? bDay = dateParser.Decode(birthday); Assert.IsNotNull(bDay); Assert.AreEqual(31, bDay.Value.Day); Assert.AreEqual(1970, bDay.Value.Year); Assert.AreEqual(07, bDay.Value.Month); decimal wrong = 0m; DateTime?wrongDay = dateParser.Decode(wrong); Assert.IsNull(wrongDay); decimal antics = -500731m; DateTime?anticsDay = dateParser.Decode(antics); Assert.IsNull(anticsDay); }