public void FilterByStatus_OriginalStatusIsUnspecified_ShouldReturnAllStatuses() { VerifyTestPreconditionsOrThrow(); var dataContext = GetDataContext(); var settings = new ConnectionStatusChangeReportSettings(); ConnectionStatusChangeReportBuilder reportBuilder; ConnectionStatusChangeReportData report; var attendeeStatusId = GetStatusValueIdOrThrow("Attendee"); var memberStatusId = GetStatusValueIdOrThrow("Member"); // Get an unfiltered report. // The unfiltered data should contain at least one record that is a transition from Visitor. Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.OldConnectionStatusId == attendeeStatusId), "Status expected but not found. [Status=Attendee]"); // Get a filtered report: Original Status=Attendee, UpdatedStatus=Member. reportBuilder = new ConnectionStatusChangeReportBuilder(dataContext, settings); settings.ToConnectionStatusId = GetStatusValueIdOrThrow("Member"); report = reportBuilder.CreateReport(); // The report should include events for new people, represented by a change from (null) --> (some status). Assert.That.IsTrue(report.ChangeEvents.Any(x => string.IsNullOrEmpty(x.OldConnectionStatusName)), "Status expected but not found. [OldStatus=(empty)]"); }
public void FilterByStatus_OriginalAndUpdatedStatusSpecified_ShouldReturnMatchingStatusesOnly() { VerifyTestPreconditionsOrThrow(); var dataContext = this.GetDataContext(); var settings = new ConnectionStatusChangeReportSettings(); ConnectionStatusChangeReportBuilder reportBuilder; ConnectionStatusChangeReportData report; var memberConnectionStatusId = GetStatusValueIdOrThrow("Member"); var attendeeConnectionStatusId = GetStatusValueIdOrThrow("Attendee"); var visitorConnectionStatusId = GetStatusValueIdOrThrow("Visitor"); var prospectConnectionStatusId = GetStatusValueIdOrThrow("Prospect"); // Get an unfiltered report. // The unfiltered data should contain Original Status=[Attendee|Prospect]. Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.OldConnectionStatusId == attendeeConnectionStatusId), "Status expected but not found. [Status=Attendee]"); Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.OldConnectionStatusId == prospectConnectionStatusId), "Status expected but not found. [Status=Prospect]"); // Get a filtered report: Original Status=Attendee, UpdatedStatus=Member. // The filtered data should only contain Original Status=Attendee. settings.FromConnectionStatusId = attendeeConnectionStatusId; settings.ToConnectionStatusId = memberConnectionStatusId; reportBuilder = new ConnectionStatusChangeReportBuilder(dataContext, settings); report = reportBuilder.CreateReport(); Assert.That.IsTrue(!report.ChangeEvents.Any(x => x.OldConnectionStatusId != attendeeConnectionStatusId), "Status found but not expected."); }
/// <summary> /// Create the report data. /// </summary> private void LoadReport() { var settings = GetReportSettingsFromPage(); // Get an instance of the report builder. var dataContext = this.GetDataContext(); var reportService = new ConnectionStatusChangeReportBuilder(dataContext, settings); var report = reportService.CreateReport(); // Create the report data to be presented. _report = new ReportDataViewModel(); _report.EndDate = report.EndDate; _report.StartDate = report.StartDate; // Get the set of changes that represent activity during the reporting period. _changeEvents = new List <StatusChangeViewModel>(); var modelsAdded = GetChangeEventViewModels(report.ChangeEvents); _changeEvents.AddRange(modelsAdded); BindReport(); }
/// <summary> /// Returns a report that contains all of the available test data for comparison results. /// </summary> /// <returns></returns> private static void CreateBaselineReport(RockContext dataContext) { var settings = new ConnectionStatusChangeReportSettings(); ConnectionStatusChangeReportBuilder reportBuilder; // Get an unfiltered report. reportBuilder = new ConnectionStatusChangeReportBuilder(dataContext, settings); _BaselineReport = reportBuilder.CreateReport(); }
/// <summary> /// Returns a report that contains all of the available test data for comparison results. /// </summary> /// <returns></returns> private ConnectionStatusChangeReportData GetBaselineReport() { if (_BaselineReport == null) { var dataContext = new RockContext(); var settings = new ConnectionStatusChangeReportSettings(); ConnectionStatusChangeReportBuilder reportBuilder; // Get an unfiltered report. reportBuilder = new ConnectionStatusChangeReportBuilder(dataContext, settings); _BaselineReport = reportBuilder.CreateReport(); } return(_BaselineReport); }
public void FilterByCampus_MatchesExist_ShouldReturnPeopleInMatchedCampusOnly() { VerifyTestPreconditionsOrThrow(); var dataContext = GetDataContext(); // Get an unfiltered report and verify that it contains records for Campus "Main". // This establishes the baseline for the test. Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.CampusId == _MainCampusId), "History events expected but not found. [Campus=(unfiltered)"); // The standard test data set does not currently have data for people in multiple campuses. // As an alternative, create a filtered report for a non-existent Campus and verify that no records are returned. var settings = new ConnectionStatusChangeReportSettings(); settings.CampusId = _InvalidCampusId; var reportService = new ConnectionStatusChangeReportBuilder(dataContext, settings); var reportFiltered = reportService.CreateReport(); Assert.That.IsFalse(reportFiltered.ChangeEvents.Any(x => x.CampusId == _MainCampusId), "History events found but not expected. [CampusId=999]"); }
public void Performance_LargeHistoryDataSet_ShouldNotTimeout() { VerifyTestPreconditionsOrThrow(); int monthsToInclude = 2; var periodStart = new DateTime(RockDateTime.Now.Year, RockDateTime.Now.Month, 1); // Run a series of monthly reports throughout the year to test performance for various time periods. for (int i = 1; i <= 12; i++) { var dataContext = GetDataContext(); periodStart = periodStart.AddMonths(monthsToInclude * -1); var nextPeriodEnd = periodStart.AddMonths(monthsToInclude).AddDays(-1); var settings = new ConnectionStatusChangeReportSettings(); settings.ReportPeriod.SetToSpecificDateRange(periodStart, nextPeriodEnd); ConnectionStatusChangeReportBuilder reportBuilder; ConnectionStatusChangeReportData report; // Get an unfiltered report. // The unfiltered data should contain at least one record that is a transition from Visitor. reportBuilder = new ConnectionStatusChangeReportBuilder(dataContext, settings); var watch = new Stopwatch(); watch.Start(); report = reportBuilder.CreateReport(); watch.Stop(); Debug.Print($"Pass {i:00}: Period={report.StartDate:dd-MMM-yy} - {report.EndDate:dd-MMM-yy}, Events={report.ChangeEvents.Count}, Execution Time={watch.Elapsed.TotalSeconds}s"); } }
public void FilterByCurrentYear_MatchesExist_ShouldReturnChangesInCurrentYearOnly() { VerifyTestPreconditionsOrThrow(); var dataContext = GetDataContext(); // Get an unfiltered report and verify that it contains records for this year and previous years. // This establishes the baseline for the test. int currentYear = RockDateTime.Now.Year; Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.EventDate.Year == currentYear), "History events expected but not found. [EventDate=(current year)"); Assert.That.IsTrue(_BaselineReport.ChangeEvents.Any(x => x.EventDate.Year == (currentYear - 1)), "History events expected but not found. [EventDate=(previous year)"); // Create a filtered report for current year only. var settings = new ConnectionStatusChangeReportSettings(); settings.ReportPeriod.SetToCurrentPeriod(TimePeriodUnitSpecifier.Year); var reportService = new ConnectionStatusChangeReportBuilder(dataContext, settings); var reportFiltered = reportService.CreateReport(); Assert.That.IsFalse(reportFiltered.ChangeEvents.Any(x => x.EventDate.Year != currentYear), "History events found but not expected. [EventDate != (current year)]"); }