Beispiel #1
0
        public void Test_Clear()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false);

            instance.Clear();
            Assert.AreEqual("", instance.StringValue);
        }
Beispiel #2
0
        public void Test_SetYear()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false);

            instance.Year = 2001;
            Assert.AreEqual(2001, instance.Year);
        }
Beispiel #3
0
        public void Test_SetYearModifier()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false);

            instance.YearModifier = "2";
            Assert.AreEqual("20 JAN 1980/2", instance.StringValue);
        }
Beispiel #4
0
        public void Test_SetMonth()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false);

            instance.Month = 12;
            Assert.AreEqual(12, instance.Month);
        }
Beispiel #5
0
 public void Test_CreateByFormattedStr_String_boolean()
 {
     Assert.AreEqual(null, GDMDate.CreateByFormattedStr(null, false));
     Assert.AreEqual("20 DEC 1980", GDMDate.CreateByFormattedStr("20/12/1980", false).StringValue);
     Assert.AreEqual("DEC 1980", GDMDate.CreateByFormattedStr("__/12/1980", false).StringValue);
     Assert.AreEqual(null, GDMDate.CreateByFormattedStr("1980", false));
     //Assert.Throws(typeof(GEDCOMDateException), () => { GEDCOMDate.createByFormattedStr("1980", true); });
 }
Beispiel #6
0
        public void Test_DateChanged()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("31/11/1980", true);
            //instance.dateChanged();
            string result = instance.GetUDN().ToString();

            Assert.AreEqual("1980/12/01", result);
        }
Beispiel #7
0
 public void Test_CreateByFormattedStr_3args()
 {
     Assert.AreEqual(null, GDMDate.CreateByFormattedStr(null, GDMCalendar.dcGregorian, false));
     Assert.AreEqual("20 DEC 1980", GDMDate.CreateByFormattedStr("20/12/1980", GDMCalendar.dcGregorian, false).StringValue);
     Assert.AreEqual("DEC 1980", GDMDate.CreateByFormattedStr("__/12/1980", GDMCalendar.dcGregorian, false).StringValue);
     Assert.AreEqual(null, GDMDate.CreateByFormattedStr("1980", GDMCalendar.dcGregorian, false));
     //Assert.Throws(typeof(GEDCOMDateException), () => { GEDCOMDate.createByFormattedStr("1980", GEDCOMCalendar.dcGregorian, true); });
 }
Beispiel #8
0
        public void Test_GetDateCalendar()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", false);

            Assert.AreEqual(GDMCalendar.dcGregorian, instance.DateCalendar);

            instance = GDMDate.CreateByFormattedStr("20/12/1980", GDMCalendar.dcJulian, false);
            Assert.AreEqual(GDMCalendar.dcJulian, instance.DateCalendar);
        }
Beispiel #9
0
        public void Test_GetUDN()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", true);
            UDN     result   = instance.GetUDN();

            UDN expResult = new UDN(UDNCalendarType.ctGregorian, 1980, 12, 20);

            Assert.IsTrue(expResult.Equals(result));
            Assert.AreEqual(expResult, result);
        }
Beispiel #10
0
        public void Test_IsValidDate()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("31/11/1980", true);

            Assert.AreEqual(true, instance.IsValidDate());

            instance = new GDMDate(null);
            Assert.AreEqual(false, instance.IsValidDate());

            // month is unknown
            instance = GDMDate.CreateByFormattedStr("31/  /1980", true);
            Assert.AreEqual(false, instance.IsValidDate());
        }
Beispiel #11
0
        public void Test_GetDisplayString_DateFormat()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", true);
            string  result   = instance.GetDisplayString(DateFormat.dfYYYY_MM_DD);

            Assert.AreEqual("1980.12.20", result);

            result = instance.GetDisplayString(DateFormat.dfDD_MM_YYYY);
            Assert.AreEqual("20.12.1980", result);

            result = instance.GetDisplayString(DateFormat.dfYYYY);
            Assert.AreEqual("1980", result);
        }
Beispiel #12
0
        public void Test_GetDateTime()
        {
            GDMDate  instance = GDMDate.CreateByFormattedStr("20/01/1980", false);
            DateTime expResult;

            try {
                expResult = ParseDT("1980-01-20");
                DateTime result = instance.GetDateTime();
                Assert.AreEqual(expResult, result);
            } catch (Exception) {
                Assert.Fail("Parse exception for date");
            }
        }
Beispiel #13
0
        public void Test_Equals()
        {
            GDMDate instance  = GDMDate.CreateByFormattedStr("20/01/1980", false);
            GDMDate instance2 = GDMDate.CreateByFormattedStr("21/01/1980", false);

            Assert.IsFalse(instance.Equals(instance2));
            Assert.IsFalse(instance.Equals((object)instance2)); // other method

            instance2.Assign(instance);

            Assert.IsTrue(instance.Equals(instance2));
            Assert.IsTrue(instance.Equals((object)instance2)); // other method

            Assert.IsFalse(instance.Equals((object)null));
        }
Beispiel #14
0
        public static UDN GetUDNByFormattedStr(string dateStr, GDMCalendar calendar, bool aException = false)
        {
            GDMDate dtx = GDMDate.CreateByFormattedStr(dateStr, calendar, aException);

            return((dtx != null) ? dtx.GetUDN() : UDN.CreateEmpty());
        }
Beispiel #15
0
        public void Test_GetDay()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", false);

            Assert.AreEqual(20, instance.Day);
        }
Beispiel #16
0
 public void Test_CreateByFormattedStr_exception()
 {
     Assert.Throws(typeof(GDMDateException), () => {
         GDMDate.CreateByFormattedStr("1.2", true);
     });
 }
Beispiel #17
0
        public void Test_GetDisplayString_DateFormat_boolean()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", true);

            Assert.AreEqual("20.12.1980", instance.GetDisplayString(DateFormat.dfDD_MM_YYYY, false));
        }