コード例 #1
0
		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;
		}
コード例 #2
0
        public void DisplayReport(Report report)
        {
            _report = report;

            ClearView();
            BuildChart();
        }
コード例 #3
0
		public void Ctor_HasEmptyItemsList()
		{
			// arrange
			var report = new Report(CreateReportQuery());
			
			// assert
			Assert.That(report.Items.Count, Is.EqualTo(0));
		}
コード例 #4
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));
		}
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
		public void Ctor_SetsReportQuery()
		{
			// arrange
			var query = CreateReportQuery();
			
			// act
			var report = new Report(query);

			// assert
			Assert.That(report.Query, Is.EqualTo(query));
		}
コード例 #8
0
		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"));
		}
コード例 #9
0
		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());
        }
コード例 #11
0
 public void DisplayReport(Report report)
 {
     _chartView.DisplayReport(report);
 }