public void AllowedTransitionsTest() { RevisionTransitionFilter filter = new RevisionTransitionFilter(); Bug[] bugs = m_provider.GetBugs(); Revision[] revisions = m_provider.GetRevisions(bugs[0].Number); var transitions = new List<RevisionStatusTransition>(filter.GetTransitions(revisions)); var transitionsExp = new List<RevisionStatusTransition> { new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "DontExist" }, PreviousRevision = null, CurrentGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, CurrentRevision = new Revision { BugNumber = 1, Rev = 0 } }, new RevisionStatusTransition { Name = "Removed", PreviousGroup = new RevisionStatusGroup { Name = "ForWork" }, PreviousRevision = new Revision { BugNumber = 1, Rev = 3 }, CurrentGroup = new RevisionStatusGroup { Name = "ForTesting" }, CurrentRevision = new Revision { BugNumber = 1, Rev = 4 } } }; CollectionAssert.AreEqual(transitionsExp, transitions, new RevisionStatusTransitionComparer()); }
// [DeploymentItem("BugDB.Reporter.dll")] public void AllowedTransitionsTest() { RevisionTransitionFilter filter = new RevisionTransitionFilter(); Bug[] bugs = m_provider.GetBugs(); Revision[] revisions = m_provider.GetRevisions(bugs[0].Number); var transitions = new List <RevisionStatusTransition>(filter.GetTransitions(revisions)); var transitionsExp = new List <RevisionStatusTransition> { new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "DontExist" }, PreviousRevision = null, CurrentGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, CurrentRevision = new Revision { BugNumber = 1, Rev = 0 } }, new RevisionStatusTransition { Name = "Removed", PreviousGroup = new RevisionStatusGroup { Name = "ForWork" }, PreviousRevision = new Revision { BugNumber = 1, Rev = 3 }, CurrentGroup = new RevisionStatusGroup { Name = "ForTesting" }, CurrentRevision = new Revision { BugNumber = 1, Rev = 4 } } }; CollectionAssert.AreEqual(transitionsExp, transitions, new RevisionStatusTransitionComparer()); }
/// <summary> /// Returns data set containing all data for the report. /// </summary> /// <remarks> /// Returned data set contains following tables: /// +) Bugfixing periods (Periods) /// +) Bugfixing statistics (Statistics) /// +) Report information (Info) /// /// -------------------------------------------------- /// Bugfixing periods contains information on Added, /// Postponed, Reactivated, Removed bugs for each /// time period and additionally two balances - /// with Postponed/Reactivated and with only Added/Removed /// accounted. /// /// There are following columns in the table: /// +) Interval - interval index /// +) FromDate - period start date /// +) ToDate - period end date /// +) Added - number of Add transition during period /// +) Postponed - -//- /// +) Reactivated - -//- /// +) Removed - -//- /// +) Balance1 - balance with Postponed/Reactivated /// +) Balance2 - balance with only Added/Removed /// /// Each row contains information for one time period. /// /// -------------------------------------------------- /// Bugfixing statistics table contains information on /// Sum, Average per period and Average per day statistics. /// /// There are following columns in the table: /// +) Aggregate - name of aggregate (Sum, Avg, AvgDay) /// +) Added - value of aggregate for Added through all periods /// +) Postponed - -//- for Postponed /// +) Reactivated - -//- /// +) Removed - -//- /// +) Balance1 - -//- /// +) Balance2 - -//- /// /// -------------------------------------------------- /// Report information table contains parameters /// for which report was created: /// +) GroupPeriod - Day, Week, etc /// +) FromDate - start date of report /// +) ToDate - end date of report /// +) MinDate - minimum date of handled revision /// +) MaxDate - maximum date of handled revision /// </remarks> public DataSet CreateReport() { // Create data set ProjectStatisticDataSet dataSet = new ProjectStatisticDataSet(); // Use filter to iterate through revisions RevisionTransitionFilter filter = new RevisionTransitionFilter(); // Select transition which fall into desired time interval // Group them by interval index // Order groups by interval index var query = from t in filter.GetTransitions(m_revisions) where t.CurrentRevision.Date >= m_fromDate && t.CurrentRevision.Date <= m_toDate group t by GetGroup(m_groupBy, t.CurrentRevision) into g orderby g.Key.Interval select g; DateTime minDate = DateTime.MaxValue, maxDate = DateTime.MinValue; int prevInterval = -1; // Count transitions foreach(var group in query) { // Initialize values int added = 0; int postponed = 0; int reactivated = 0; int removed = 0; // Update values for all revisions in group foreach(RevisionStatusTransition transition in group) { // Update correspondent values added += transition.Name == "Added" ? 1 : 0; postponed += transition.Name == "Postponed" ? 1 : 0; reactivated += transition.Name == "Reactivated" ? 1 : 0; removed += transition.Name == "Removed" ? 1 : 0; // Remember min/max dates if( transition.CurrentRevision.Date < minDate ) { minDate = transition.CurrentRevision.Date; } if( transition.CurrentRevision.Date > maxDate ) { maxDate = transition.CurrentRevision.Date; } } // Fill gaps between nonempty periods with zero rows if (prevInterval != -1 && group.Key.Interval > (prevInterval + 1)) { for (int interval = prevInterval + 1; interval < group.Key.Interval; interval++) { DateTime fromDate, toDate; GetIntervalDates(m_groupBy, interval, out fromDate, out toDate); dataSet.Periods.AddPeriodsRow(interval, fromDate, toDate, 0, 0, 0, 0); } } // Add row for current group dataSet.Periods.AddPeriodsRow(group.Key.Interval, group.Key.IntervalStart, group.Key.IntervalEnd, added, postponed, reactivated, removed); // Remember current interval prevInterval = group.Key.Interval; } // Fill info table dataSet.Info.AddInfoRow(m_fromDate, m_toDate, m_groupBy.ToString(), minDate, maxDate); // Fill statistics table return dataSet; }
/// <summary> /// Returns data set containing all data for the report. /// </summary> /// <remarks> /// Returned data set contains following tables: /// +) Bugfixing periods (Periods) /// +) Bugfixing statistics (Statistics) /// +) Report information (Info) /// /// -------------------------------------------------- /// Bugfixing periods contains information on Added, /// Postponed, Reactivated, Removed bugs for each /// time period and additionally two balances - /// with Postponed/Reactivated and with only Added/Removed /// accounted. /// /// There are following columns in the table: /// +) Interval - interval index /// +) FromDate - period start date /// +) ToDate - period end date /// +) Added - number of Add transition during period /// +) Postponed - -//- /// +) Reactivated - -//- /// +) Removed - -//- /// +) Balance1 - balance with Postponed/Reactivated /// +) Balance2 - balance with only Added/Removed /// /// Each row contains information for one time period. /// /// -------------------------------------------------- /// Bugfixing statistics table contains information on /// Sum, Average per period and Average per day statistics. /// /// There are following columns in the table: /// +) Aggregate - name of aggregate (Sum, Avg, AvgDay) /// +) Added - value of aggregate for Added through all periods /// +) Postponed - -//- for Postponed /// +) Reactivated - -//- /// +) Removed - -//- /// +) Balance1 - -//- /// +) Balance2 - -//- /// /// -------------------------------------------------- /// Report information table contains parameters /// for which report was created: /// +) GroupPeriod - Day, Week, etc /// +) FromDate - start date of report /// +) ToDate - end date of report /// +) MinDate - minimum date of handled revision /// +) MaxDate - maximum date of handled revision /// </remarks> public DataSet CreateReport() { // Create data set ProjectStatisticDataSet dataSet = new ProjectStatisticDataSet(); // Use filter to iterate through revisions RevisionTransitionFilter filter = new RevisionTransitionFilter(); // Select transition which fall into desired time interval // Group them by interval index // Order groups by interval index var query = from t in filter.GetTransitions(m_revisions) where t.CurrentRevision.Date >= m_fromDate && t.CurrentRevision.Date <= m_toDate group t by GetGroup(m_groupBy, t.CurrentRevision) into g orderby g.Key.Interval select g; DateTime minDate = DateTime.MaxValue, maxDate = DateTime.MinValue; int prevInterval = -1; // Count transitions foreach (var group in query) { // Initialize values int added = 0; int postponed = 0; int reactivated = 0; int removed = 0; // Update values for all revisions in group foreach (RevisionStatusTransition transition in group) { // Update correspondent values added += transition.Name == "Added" ? 1 : 0; postponed += transition.Name == "Postponed" ? 1 : 0; reactivated += transition.Name == "Reactivated" ? 1 : 0; removed += transition.Name == "Removed" ? 1 : 0; // Remember min/max dates if (transition.CurrentRevision.Date < minDate) { minDate = transition.CurrentRevision.Date; } if (transition.CurrentRevision.Date > maxDate) { maxDate = transition.CurrentRevision.Date; } } // Fill gaps between nonempty periods with zero rows if (prevInterval != -1 && group.Key.Interval > (prevInterval + 1)) { for (int interval = prevInterval + 1; interval < group.Key.Interval; interval++) { DateTime fromDate, toDate; GetIntervalDates(m_groupBy, interval, out fromDate, out toDate); dataSet.Periods.AddPeriodsRow(interval, fromDate, toDate, 0, 0, 0, 0); } } // Add row for current group dataSet.Periods.AddPeriodsRow(group.Key.Interval, group.Key.IntervalStart, group.Key.IntervalEnd, added, postponed, reactivated, removed); // Remember current interval prevInterval = group.Key.Interval; } // Fill info table dataSet.Info.AddInfoRow(m_fromDate, m_toDate, m_groupBy.ToString(), minDate, maxDate); // Fill statistics table return(dataSet); }
public void ForbiddenTransitionsTest() { RevisionTransitionFilter filter = new RevisionTransitionFilter(); Bug[] bugs = m_provider.GetBugs(); Revision[] revisions = m_provider.GetRevisions(bugs[2].Number); var transitions = new List<RevisionStatusTransition>(filter.GetTransitions(revisions)); var transitionsExp = new List<RevisionStatusTransition> { new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "DontExist" }, PreviousRevision = null, CurrentGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 0 }, IsForbidden = false }, new RevisionStatusTransition { Name = "Removed", PreviousGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, PreviousRevision = new Revision { BugNumber = 3, Rev = 0 }, CurrentGroup = new RevisionStatusGroup { Name = "Finished" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 1 }, IsForbidden = true }, new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "Finished" }, PreviousRevision = new Revision { BugNumber = 3, Rev = 1 }, CurrentGroup = new RevisionStatusGroup { Name = "ForWork" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 2 }, IsForbidden = true } }; CollectionAssert.AreEqual(transitionsExp, transitions, new RevisionStatusTransitionComparer()); }
public void ForbiddenTransitionsTest() { RevisionTransitionFilter filter = new RevisionTransitionFilter(); Bug[] bugs = m_provider.GetBugs(); Revision[] revisions = m_provider.GetRevisions(bugs[2].Number); var transitions = new List <RevisionStatusTransition>(filter.GetTransitions(revisions)); var transitionsExp = new List <RevisionStatusTransition> { new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "DontExist" }, PreviousRevision = null, CurrentGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 0 }, IsForbidden = false }, new RevisionStatusTransition { Name = "Removed", PreviousGroup = new RevisionStatusGroup { Name = "ForAnalysis" }, PreviousRevision = new Revision { BugNumber = 3, Rev = 0 }, CurrentGroup = new RevisionStatusGroup { Name = "Finished" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 1 }, IsForbidden = true }, new RevisionStatusTransition { Name = "Added", PreviousGroup = new RevisionStatusGroup { Name = "Finished" }, PreviousRevision = new Revision { BugNumber = 3, Rev = 1 }, CurrentGroup = new RevisionStatusGroup { Name = "ForWork" }, CurrentRevision = new Revision { BugNumber = 3, Rev = 2 }, IsForbidden = true } }; CollectionAssert.AreEqual(transitionsExp, transitions, new RevisionStatusTransitionComparer()); }