public void ShouldIncludeTheCorrectDataInTimeSpans()
        {
            var now = new DateTime(2013, 4, 23);

            //Is Tuesday
            Assert.IsTrue(now.DayOfWeek == DayOfWeek.Tuesday);

            var weeklyDataHelper = new WeeklyTrainigDataSummary();

            weeklyDataHelper.FirstDayOfTheWeek = DataUtils.GetDayNumber("Thursday");

            IList <TimeSpan> weeklyspans = weeklyDataHelper.GetTimeSpans(now, Constants.NUMBER_OF_WEEK_RECORDS);

            var energyevels = new List <DailyEnergyLevel>
            {
                new DailyEnergyLevel {
                    EnergyLevel = 0, Date = new DateTime(2013, 4, 19)
                },
                new DailyEnergyLevel {
                    EnergyLevel = 3, Date = new DateTime(2013, 4, 22)
                },
                new DailyEnergyLevel {
                    EnergyLevel = 3, Date = new DateTime(2013, 4, 23)
                },
            };

            var dataHelper = new WeeklyDataHelper();

            List <ServiceModel.EnergyLevel.EnergyLevelInfo> data = dataHelper.FillRecordsOnEmptyTimeSpans(energyevels,
                                                                                                          weeklyspans);

            Assert.IsTrue(data[0].Value == (energyevels.Sum(e => e.EnergyLevel) / energyevels.Count));
        }
        public List <TimeSpan> WeeklyDataHelperGenerateCorrectTimeSpans()
        {
            var targetWeeklyTieSpans = new List <WeeklyTimeSpan>
            {
                new WeeklyTimeSpan {
                    StartDate = new DateTime(2013, 4, 22), EndDate = new DateTime(2013, 4, 23)
                },
                new WeeklyTimeSpan {
                    StartDate = new DateTime(2013, 4, 15), EndDate = new DateTime(2013, 4, 21)
                },
                new WeeklyTimeSpan {
                    StartDate = new DateTime(2013, 4, 8), EndDate = new DateTime(2013, 4, 14)
                },
                new WeeklyTimeSpan {
                    StartDate = new DateTime(2013, 4, 1), EndDate = new DateTime(2013, 4, 7)
                },
            };


            var now = new DateTime(2013, 4, 23);

            //Is Tuesday
            Assert.IsTrue(now.DayOfWeek == DayOfWeek.Tuesday);

            var weeklyDataHelper = new WeeklyTrainigDataSummary();

            weeklyDataHelper.FirstDayOfTheWeek = DataUtils.GetDayNumber("Monday");

            IList <TimeSpan> weeklyspans = weeklyDataHelper.GetTimeSpans(now, Constants.NUMBER_OF_WEEK_RECORDS);

            for (int i = 0; i < targetWeeklyTieSpans.Count; i++)
            {
                //Every start date is monday
                Assert.IsTrue(((WeeklyTimeSpan)weeklyspans[i]).StartDate.DayOfWeek == DayOfWeek.Monday);

                Assert.IsTrue(((WeeklyTimeSpan)weeklyspans[i]).StartDate.Day == targetWeeklyTieSpans[i].StartDate.Day);
                Assert.IsTrue(((WeeklyTimeSpan)weeklyspans[i]).EndDate.Day == targetWeeklyTieSpans[i].EndDate.Day);
            }
            return(weeklyspans.ToList());
        }