public void GetFirstDateOfQuarter() { Assert.AreEqual(new DateTime(2018, 4, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 4, QuarterPeriod.First)); Assert.AreEqual(new DateTime(2018, 7, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 4, QuarterPeriod.Second)); Assert.AreEqual(new DateTime(2018, 10, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 4, QuarterPeriod.Third)); Assert.AreEqual(new DateTime(2019, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 4, QuarterPeriod.Fourth)); Assert.AreEqual(new DateTime(2018, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 1, QuarterPeriod.First)); Assert.AreEqual(new DateTime(2018, 4, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 1, QuarterPeriod.Second)); Assert.AreEqual(new DateTime(2018, 7, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 1, QuarterPeriod.Third)); Assert.AreEqual(new DateTime(2018, 10, 1), DateTimeUtility.GetFirstDateOfQuarter(2018, 1, QuarterPeriod.Fourth)); Assert.AreEqual(new DateTime(2018, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1), 4)); Assert.AreEqual(new DateTime(2018, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 3, 31), 4)); Assert.AreEqual(new DateTime(2018, 4, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 4, 1), 4)); Assert.AreEqual(new DateTime(2018, 4, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 6, 30), 4)); Assert.AreEqual(new DateTime(2018, 7, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 7, 1), 4)); Assert.AreEqual(new DateTime(2018, 7, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 9, 30), 4)); Assert.AreEqual(new DateTime(2018, 10, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 10, 1), 4)); Assert.AreEqual(new DateTime(2018, 10, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 12, 31), 4)); Assert.AreEqual(new DateTime(1, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(1, 1, 1), 4)); Assert.AreEqual(new DateTime(9999, 10, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(9999, 12, 31), 4)); Assert.AreEqual(new DateTime(2017, 11, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1), 2)); Assert.AreEqual(new DateTime(2018, 2, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 3, 31), 2)); Assert.AreEqual(new DateTime(2018, 2, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 4, 1), 2)); Assert.AreEqual(new DateTime(2018, 5, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 6, 30), 2)); Assert.AreEqual(new DateTime(2018, 5, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 7, 1), 2)); Assert.AreEqual(new DateTime(2018, 8, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 9, 30), 2)); Assert.AreEqual(new DateTime(2018, 8, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 10, 1), 2)); Assert.AreEqual(new DateTime(2018, 11, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 12, 31), 2)); // Assert.AreEqual(new DateTime(0, 11, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(1, 1, 1), 2)); Assert.AreEqual(new DateTime(9999, 11, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(9999, 12, 31), 2)); }
public void GetFirstDateOfQuarter_Failed3() { Assert.AreEqual(DateTime.MinValue, DateTimeUtility.GetFirstDateOfQuarter(new DateTime(1, 1, 1), 2)); }
public void GetFirstDateOfQuarter_Failed2() { Assert.AreEqual(new DateTime(2018, 1, 1), DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1), 13)); }
public void GetFirstDateOfQuarter_Kind() { Assert.AreEqual(DateTimeKind.Unspecified, DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1), 4).Kind); Assert.AreEqual(DateTimeKind.Local, DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1, 0, 0, 0, DateTimeKind.Local), 4).Kind); Assert.AreEqual(DateTimeKind.Utc, DateTimeUtility.GetFirstDateOfQuarter(new DateTime(2018, 1, 1, 0, 0, 0, DateTimeKind.Utc), 4).Kind); }