public Report Create(ReportQuery query) { var report = new Report(query); var filter = SearchErrorLogQuery.Create(query); var errors = _repository.GetWithFilter(filter); switch (query.ReportType) { case ReportTypes.Type: CreateByTypesReport(report, errors, query.NumberOfResults); break; case ReportTypes.Source: CreateBySourceReport(report, errors, query.NumberOfResults); break; case ReportTypes.User: CreateByUsersReport(report, errors, query.NumberOfResults); break; case ReportTypes.Url: CreateByUrlReport(report, errors, query.NumberOfResults); break; case ReportTypes.Day: CreateByDayReport(report, errors, query.NumberOfResults); break; case ReportTypes.Browser: CreateByBrowserReport(report, errors, query.NumberOfResults); break; } return report; }
public void DisplayReport(Report report) { _report = report; ClearView(); BuildChart(); }
public void Ctor_HasEmptyItemsList() { // arrange var report = new Report(CreateReportQuery()); // assert Assert.That(report.Items.Count, Is.EqualTo(0)); }
private static void CreateByUrlReport(Report report, IEnumerable<ErrorLog> errors, int numberOfResults) { var query = from e in errors orderby e.CleanUrl group e by e.CleanUrl into g select new ReportItem(g.Key, g.Count()); report.AddRange(GetNumberOfResults(query, numberOfResults)); }
private static void CreateByDayReport(Report report, IEnumerable<ErrorLog> errors, int numberOfResults) { var query = from e in errors orderby e.Time.Date group e by e.Time.Date into g select new ReportItem(g.Key.ToShortDateString(), g.Count()); report.AddRange(GetNumberOfResults(query, numberOfResults)); }
private static void CreateByBrowserReport(Report report, IEnumerable<ErrorLog> errors, int numberOfResults) { var query = from e in errors orderby e.ClientInformation.Browser group e by e.ClientInformation.Browser into g select new ReportItem(g.Key, g.Count()); report.AddRange(GetNumberOfResults(query, numberOfResults)); }
public void Ctor_SetsReportQuery() { // arrange var query = CreateReportQuery(); // act var report = new Report(query); // assert Assert.That(report.Query, Is.EqualTo(query)); }
public void AddRange_RangeIsNull() { // arrange var report = new Report(CreateReportQuery()); // act var result = Assert.Throws<ArgumentNullException>(() => report.AddRange(null)); // assert Assert.That(result, Is.Not.Null); Assert.That(result.ParamName, Is.EqualTo("items")); }
public void AddRange_AddsRangeToItems() { // arrange var report = new Report(CreateReportQuery()); var range = new List<ReportItem> { new ReportItem("key", 10) }; // act report.AddRange(range); // assert Assert.That(report.Items.Count, Is.EqualTo(1)); }
public void ViewOnReportSelected_DisplaysReport() { // arrange var presenter = BuildPresenter(); var reporyQuery = CreateReportQuery(); var args = new ReportSelectionEventArgs(reporyQuery); var report = new Report(reporyQuery); _generator.Setup(x => x.Create(reporyQuery)).Returns(report); // act _view.Raise(x => x.OnReportSelected += null, args); // assert _view.Verify(x => x.DisplayReport(report), Times.Once()); }
public void DisplayReport(Report report) { _chartView.DisplayReport(report); }