Ejemplo n.º 1
0
 public void EncodeDecimalTest()
 {
     DateTime birthday = new DateTime(1970, 07, 31);
     IDateParser dateParser = new DateParser();
     decimal bday = dateParser.EncodeDecimal(birthday);
     Assert.IsNotNull(bday);
     Assert.AreEqual(19700731, bday);
     DateTime max = new DateTime(9999, 12, 31);
     decimal maxDay = dateParser.EncodeDecimal(max);
     Assert.IsNotNull(maxDay);
     Assert.AreEqual(99999999, maxDay);
 }
Ejemplo n.º 2
0
 public void EncodeStringTest()
 {
     DateTime birthday = new DateTime(1970,07,31);
     IDateParser dateParser = new DateParser();
     string bday = dateParser.EncodeString(birthday);
     Assert.IsNotNull(bday);
     Assert.AreEqual("19700731",bday);
     DateTime max = new DateTime(9999, 12, 31);
     string maxDay = dateParser.EncodeString(max);
     Assert.IsNotNull(maxDay);
     Assert.AreEqual("99999999", maxDay);
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);            
        }