Exemplo n.º 1
0
        public void GivenCardsListExpectMatchingNumberOfCards()
        {
            var expectedCardCount = 9;
            var weekStats = new TrelloStats.Model.Stats.WeekStats();
            weekStats.Cards = CreateCardStats(ConfigurationFactory.DEFAULT_IN_TEST_LIST_NAME, expectedCardCount);

            Assert.AreEqual(expectedCardCount, weekStats.NumberOfCompletedCards);
        }
Exemplo n.º 2
0
        public void GivenCardsWithLabelListExpectMatchingNumberOfCardsWithLabel()
        {
            var expectedCardCount = 5;

            var labelName = "label name";
            var weekStats = new TrelloStats.Model.Stats.WeekStats();
            weekStats.Cards = CreateCardStats(ConfigurationFactory.DEFAULT_IN_TEST_LIST_NAME, expectedCardCount);
            weekStats.Cards.ToList().ForEach(c=>c.CardData.Card.Labels = new List<TrelloNet.Card.Label>(){ new TrelloNet.Card.Label(){Name = labelName}});

            Assert.AreEqual(expectedCardCount, weekStats.GetNumberOfCardsWithLabel(labelName));
        }
Exemplo n.º 3
0
        public void GivenCardsWithPointsExpectTotalPointsToBeSumOfCardPoints()
        {
            var pointsPerCard = 2;
            var cardCount = 5;
            var expectedTotalPoints = pointsPerCard * cardCount;

            var weekStats = new TrelloStats.Model.Stats.WeekStats();
            weekStats.Cards = CreateCardStats(ConfigurationFactory.DEFAULT_IN_TEST_LIST_NAME, cardCount);
            weekStats.Cards.ToList().ForEach(c => c.CardData.Points = pointsPerCard);

            Assert.AreEqual(expectedTotalPoints, weekStats.PointsCompleted);
        }
Exemplo n.º 4
0
        //public void GetTotalCompletedPointsAsOfDate(DateTime date)
        //{
        //    var points = BoardStats.CardStats.Where(c => c.DoneAction.Date < date).Sum(c => c.CardData.Points);
        //}
        private List<WeekStats> GetWeeklyStats()
        {
            var weekStatsList = new List<WeekStats>();

            for (int week = 1; week <= CompletedWeeksElapsed +1; week++)
            {

                var startDay = BoardStats.ProjectStartDate.AddDays(week * 7);

                //TODO: Why does this occasionally go past the current week. Occured on July 31st and august 1st.
                if (startDay > DateTime.Now)
                    continue;
                var endDay = startDay.AddDays(7);
                if(startDay.DayOfWeek != DayOfWeek.Monday || endDay.DayOfWeek != DayOfWeek.Monday)
                {

                }
                var completedCards = BoardStats.CardStats.Where(c => !c.IsInProgress && !c.IsInTest && c.DoneAction.DateInTimeZone(_configuration.TimeZone) >= startDay && c.DoneAction.DateInTimeZone(_configuration.TimeZone) < endDay);
                var inProgressCards = BoardStats.CardStats.Where(c => c.IsInProgress && c.EffectiveStartAction.DateInTimeZone(_configuration.TimeZone) >= startDay && c.EffectiveStartAction.DateInTimeZone(_configuration.TimeZone) < endDay);
                var inTestCards = BoardStats.CardStats.Where(c => c.IsInTest && c.EffectiveStartAction.DateInTimeZone(_configuration.TimeZone) >= startDay && c.EffectiveStartAction.DateInTimeZone(_configuration.TimeZone) < endDay);
                var timesheetEntries = BoardStats.TimesheetData.Where(t => t.Week == week && t.Category != _configuration.GoogleTimesheetsExcludeCategoryFromTotalHours).ToList();
                var excludedTimesheetEntries = BoardStats.TimesheetData.Where(t => t.Week == week && t.Category == _configuration.GoogleTimesheetsExcludeCategoryFromTotalHours).ToList();

                WeekStats weekStats = new WeekStats() { Cards = completedCards, CardsInProgress = inProgressCards, CardsInTest = inTestCards, WeekNumber = week, StartDate = startDay, EndDate = endDay, TimesheetEntries = timesheetEntries, ExcludedTimesheetEntries = excludedTimesheetEntries };
                weekStatsList.Add(weekStats);
            }
            return weekStatsList;
        }
Exemplo n.º 5
0
        private string GetWeekStatsHtmlRow(WeekStats w, BoardStatsAnalysis boardStatsAnalysis)
        {
            var row = new StringBuilder("<tr>");
            row.AppendLine(GetWeekStatsRow(w.WeekNumber));

            row.AppendLine(GetWeekStatsRow(w.StartDate.ToShortDateString(), "date"));
            row.AppendLine(GetWeekStatsRow(w.EndDate.ToShortDateString(), "date"));
            row.AppendLine(GetWeekStatsRow(GetNumberForTableDisplay(w.NumberOfCardsInProgress),"text-center"));
            row.AppendLine(GetWeekStatsRow(GetNumberForTableDisplay(w.NumberOfCardsInTest),"text-center"));

            row.AppendLine(GetWeekStatsRow(GetNumberForTableDisplay(w.NumberOfCompletedCards),"text-center"));

            foreach (var labelName in _configuration.LabelNames)
            {
                var labelNameSet = labelName.Split('/');
                if (labelNameSet.Length > 1)
                {
                    var value1 = w.GetNumberOfCardsWithLabel(labelNameSet[0]);
                    var value2 = w.GetNumberOfCardsWithLabel(labelNameSet[1]);
                    var valueSet = String.Format("{0}/{1}", value1, value2);
                    row.AppendLine(GetWeekStatsRow(valueSet,"text-center"));
                }
                else
                {
                    row.AppendLine(GetWeekStatsRow(GetNumberForTableDisplay(w.GetNumberOfCardsWithLabel(labelName)),"text-center"));
                }
            }

            row.AppendLine(GetWeekStatsRow(w.PointsCompleted,"text-center"));

            var hoursString = string.Format("{0}/{1}",Math.Ceiling(w.TotalHours),Math.Ceiling(w.TotalExcludedHours));
            row.AppendLine(GetWeekStatsRow(hoursString, "text-center"));

            row.Append("</tr>");

            return row.ToString();
        }