private IEnumerable <string> GetAllWeeksBetween(DateTime start, DateTime end) { List <string> filePaths = new List <string>(); ITimeWindow window = new DayTimeWindow(start); window = window.ToWeekWindow(); while (end > window.EndTime) { string fileName = GetWeekSummary(window.EndTime); if (File.Exists(fileName)) { filePaths.Add(fileName); } window.GoNext(); } return(filePaths); }
public void Basic_ListAtom_GroupedDataFormat_ByWeek() { // Aggregation if same activity??? DateTime date = new DateTime(2012, 4, 1, 1, 1, 1); ITimeWindow window = new DayTimeWindow(date).ToWeekWindow(); ITimeWindow windowNext = new DayTimeWindow(date).ToWeekWindow(); windowNext.GoNext(); List <DataAtom> list = new List <DataAtom>() { new DataAtom() { Time = window.StartTime.AddDays(1), Process = "Foo", // activity Title = "Foo title", // not bubbled yet Frequency = 5 // aggregated }, new DataAtom() { Time = window.StartTime.AddDays(2), Process = "Foo", // activity Title = "Foo title", // not bubbled yet Frequency = 5 // aggregated }, new DataAtom() { Time = window.StartTime.AddDays(3).AddMinutes(1), Process = "Bar", // activity Title = "Foo title", // not bubbled yet Frequency = 20 // aggregated }, new DataAtom() { Time = windowNext.StartTime.AddDays(1), Process = "Qux", // activity Title = "Foo title", // not bubbled yet Frequency = 30 // aggregated } }; List <GroupedDataFormat> expected = new List <GroupedDataFormat>() { new GroupedDataFormat() { GroupBy = window.StartTime, Activity = new[] { "Bar", "Foo" }, TimeSpan = new long[] { 20, 10 } // aggregated over start - end, but grouped by group by }, new GroupedDataFormat() { GroupBy = windowNext.StartTime, Activity = new[] { "Qux" }, TimeSpan = new long[] { 30 } // aggregated over start - end, but grouped by group by } }; var actual = new DataFormatConvertor(list).ToGroupedDataFormat(); Assert.AreEqual(expected.Count, actual.Count()); var zipped = expected.Zip(actual, (e, a) => new { Expected = e, Actual = a }); foreach (var item in zipped) { CollectionAssert.AreEqual(item.Expected.Activity, item.Actual.Activity); CollectionAssert.AreEqual(item.Expected.TimeSpan, item.Actual.TimeSpan); Assert.AreEqual(item.Expected.GroupBy.Year, item.Actual.GroupBy.Year); Assert.AreEqual(item.Expected.GroupBy.Month, item.Actual.GroupBy.Month); Assert.AreEqual(item.Expected.GroupBy.Day, item.Actual.GroupBy.Day); } }