public void Test_Clear() { GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false); instance.Clear(); Assert.AreEqual("", instance.StringValue); }
public void Test_SetYear() { GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false); instance.Year = 2001; Assert.AreEqual(2001, instance.Year); }
public void Test_SetYearModifier() { GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false); instance.YearModifier = "2"; Assert.AreEqual("20 JAN 1980/2", instance.StringValue); }
public void Test_SetMonth() { GDMDate instance = GDMDate.CreateByFormattedStr("20/01/1980", false); instance.Month = 12; Assert.AreEqual(12, instance.Month); }
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); }); }
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); }
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); }); }
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); }
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); }
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()); }
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); }
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"); } }
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)); }
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()); }
public void Test_GetDay() { GDMDate instance = GDMDate.CreateByFormattedStr("20/12/1980", false); Assert.AreEqual(20, instance.Day); }
public void Test_CreateByFormattedStr_exception() { Assert.Throws(typeof(GDMDateException), () => { GDMDate.CreateByFormattedStr("1.2", true); }); }
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)); }