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

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

            instance.Year = 2001;
            Assert.AreEqual(2001, instance.Year);
        }
예제 #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);
        }
예제 #4
0
        public void Test_SetMonth()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false);

            instance.Month = 12;
            Assert.AreEqual(12, instance.Month);
        }
예제 #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); });
 }
예제 #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);
        }
예제 #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); });
 }
예제 #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);
        }
예제 #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);
        }
예제 #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());
        }
예제 #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);
        }
예제 #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");
            }
        }
예제 #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));
        }
예제 #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());
        }
예제 #15
0
        public void Test_GetDay()
        {
            GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", false);

            Assert.AreEqual(20, instance.Day);
        }
예제 #16
0
 public void Test_CreateByFormattedStr_exception()
 {
     Assert.Throws(typeof(GDMDateException), () => {
         GDMDate.CreateByFormattedStr("1.2", true);
     });
 }
예제 #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));
        }