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;
		}
Esempio n. 2
0
		public Report(ReportQuery query)
		{
			if (query == null)
			{
				throw new ArgumentNullException("query");
			}

			Query = query;
			Items = new List<ReportItem>();
		}
        public void Ctor_SetsApplicationReportTypeDateIntervalAndNumberOfResults()
        {
            // act
            var interval = new DateInterval(new DateTime(1975, 5, 14), new DateTime(2011, 4, 8));
            var query = new ReportQuery("application", ReportTypes.Type, interval, -1);

            // assert
            Assert.That(query.Application, Is.EqualTo("application"));
            Assert.That(query.ReportType, Is.EqualTo(ReportTypes.Type));
            Assert.That(query.Interval, Is.EqualTo(interval));
            Assert.That(query.NumberOfResults, Is.EqualTo(-1));
        }
		public void Create_ReportTypeIsUser_GeneratesReport()
		{
			// arrange
			var generator = CreateGenerator();
			var query = new ReportQuery("/", ReportTypes.User, CreateInterval(), -1);

			// act
			var result = generator.Create(query);

			// assert
			Assert.That(result.Items.Count, Is.EqualTo(4));
		}
		public void Create_ReportTypeIsSourceNumberOfResultsIsThree_GeneratesReport()
		{
			// arrange
			var generator = CreateGenerator();
			var query = new ReportQuery("/", ReportTypes.Source, CreateInterval(), 3);

			// act
			var result = generator.Create(query);

			// assert
			Assert.That(result.Items.Count, Is.EqualTo(3));
		}
        public void ToString_ReportDescriptionStartAndEndTime()
        {
            // arrange
            var query = new ReportQuery("application", ReportTypes.Type, new DateInterval(new DateTime(1975, 5, 14), new DateTime(2011, 4, 8)), -1);

            // act
            var formatInfo = (DateTimeFormatInfo)DateTimeFormatInfo.InvariantInfo.Clone();
            formatInfo.ShortDatePattern = "yyyy-MM-dd";
            var result = query.ToString(formatInfo);

            // assert
            Assert.That(result, Is.EquivalentTo("Number of errors per type from 1975-05-14 to 2011-04-08"));
        }
 public ReportSelectionEventArgs(ReportQuery query)
 {
     Query = query;
 }
 public static SearchErrorLogQuery Create(ReportQuery reportQuery)
 {
     var query = new SearchErrorLogQuery { Application = reportQuery.Application, Interval = reportQuery.Interval };
     return query;
 }