public void AdvancedNormalizationWorks1() { DateTime now = DateTime.Now; PeriodCollection col = new PeriodCollection(); col.Add(new Period(now.AddHours(31), now.AddHours(34))); col.Add(new Period(now.AddHours(16), now.AddHours(18))); col.Add(new Period(now.AddHours(2), now.AddHours(5))); col.Add(new Period(now.AddHours(27), now.AddHours(28))); col.Add(new Period(now, now.AddHours(1))); col.Add(new Period(now.AddHours(4), now.AddHours(7))); col.Add(new Period(now.AddHours(3), now.AddHours(4))); col.Add(new Period(now.AddHours(9), now.AddHours(11))); col.Add(new Period(now.AddHours(24), now.AddHours(26))); col.Add(new Period(now.AddHours(2), now.AddHours(5))); col.Add(new Period(now.AddHours(11), now.AddHours(13))); col.Add(new Period(now.AddHours(25), now.AddHours(32))); col.Normalize(); Assert.AreEqual(5, col.Count); Assert.AreEqual(new Period(now, now.AddHours(1)), col[0]); Assert.AreEqual(new Period(now.AddHours(2), now.AddHours(7)), col[1]); Assert.AreEqual(new Period(now.AddHours(9), now.AddHours(13)), col[2]); Assert.AreEqual(new Period(now.AddHours(16), now.AddHours(18)), col[3]); Assert.AreEqual(new Period(now.AddHours(24), now.AddHours(34)), col[4]); }
public void NormalizationWorks() { DateTime now = DateTime.Now; PeriodCollection col = new PeriodCollection(); col.Add(new Period(now.AddHours(2), now.AddHours(5))); col.Add(new Period(now, now.AddHours(1))); col.Add(new Period(now.AddHours(4), now.AddHours(7))); col.Normalize(); Assert.AreEqual(2, col.Count); Assert.AreEqual(new Period(now, now.AddHours(1)), col[0]); Assert.AreEqual(new Period(now.AddHours(2), now.AddHours(7)), col[1]); }
public void NOTTest() { DateTime now = DateTime.Now.Date; PeriodCollection left = new PeriodCollection(); left.Add(new Period(now.AddHours(22), now.AddHours(27))); left.Add(new Period(now.AddHours(1), now.AddHours(3))); left.Add(new Period(now.AddHours(4), now.AddHours(7))); left.Add(new Period(now.AddHours(11), now.AddHours(13))); left.Add(new Period(now.AddHours(11), now.AddHours(12))); left.Add(new Period(now.AddHours(17), now.AddHours(20))); left.Add(new Period(now.AddHours(21), now.AddHours(23))); left.Add(new Period(now.AddHours(22), now.AddHours(23))); left.Add(new Period(now.AddHours(15), now.AddHours(16))); left.Add(new Period(now.AddHours(16), now.AddHours(17))); left.Add(new Period(now.AddHours(1), now.AddHours(3))); left.Add(new Period(now.AddHours(5), now.AddHours(6))); left.Add(new Period(now.AddHours(7), now.AddHours(8))); left.Add(new Period(now.AddHours(16), now.AddHours(17))); PeriodCollection expected = new PeriodCollection(left); expected.Normalize(); PeriodCollection res = left.NOT(); Assert.AreEqual(expected.Count + 1, res.Count); PeriodCollection res2 = res.NOT(); Assert.AreEqual(expected.Count, res2.Count); for (int idx = 0; idx < res2.Count; idx++) { Assert.AreEqual(expected[idx], res2[idx]); } }
public void ANDOneBigSpanAndLargeList() { DateTime now = DateTime.Now.Date; PeriodCollection left = new PeriodCollection(); left.Add(new Period(now.AddHours(22), now.AddHours(27))); left.Add(new Period(now.AddHours(1), now.AddHours(3))); left.Add(new Period(now.AddHours(4), now.AddHours(7))); left.Add(new Period(now.AddHours(11), now.AddHours(13))); left.Add(new Period(now.AddHours(11), now.AddHours(12))); left.Add(new Period(now.AddHours(17), now.AddHours(20))); left.Add(new Period(now.AddHours(21), now.AddHours(23))); left.Add(new Period(now.AddHours(22), now.AddHours(23))); left.Add(new Period(now.AddHours(15), now.AddHours(16))); left.Add(new Period(now.AddHours(16), now.AddHours(17))); left.Add(new Period(now.AddHours(1), now.AddHours(3))); left.Add(new Period(now.AddHours(5), now.AddHours(6))); left.Add(new Period(now.AddHours(7), now.AddHours(8))); left.Add(new Period(now.AddHours(16), now.AddHours(17))); PeriodCollection expected = new PeriodCollection(left); expected.Normalize(); PeriodCollection right = new PeriodCollection(); right.Add(new Period(now.AddHours(1), now.AddHours(30))); PeriodCollection res = PeriodCollection.AND(right, left); Assert.AreEqual(expected.Count, res.Count); for (int idx = 0; idx < expected.Count; idx++) { Assert.AreEqual(expected[idx], res[idx]); } }