private static void Main() { var encoding = Encoding.GetEncoding(1251); var slideRecords = My_ParsingTask.ParseSlideRecords(File.ReadAllLines("slides.txt", encoding)); var visitRecords = My_ParsingTask.ParseVisitRecords(File.ReadAllLines("visits.txt", encoding), slideRecords).ToList(); foreach (var slideType in new[] { SlideType.Theory, SlideType.Exercise, SlideType.Quiz }) { var time = My_StatisticsTask.GetMedianTimePerSlide(visitRecords, slideType); Console.WriteLine("Median time per slide '{0}': {1} mins", slideType, time); } }
public void TwoVisits() { var time = DateTime.Now; var visits = new List <VisitRecord> { new VisitRecord(1, 10, time, SlideType.Exercise), new VisitRecord(1, 11, time + TimeSpan.FromMinutes(2), SlideType.Exercise) }; var median = My_StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise); Assert.AreEqual(2, median, 1e-5); }
public void ManyVisitsOfOneUser() { var time = DateTime.Now; var visits = new List <VisitRecord> { new VisitRecord(1, 10, time, SlideType.Exercise), new VisitRecord(1, 11, time + TimeSpan.FromMinutes(2), SlideType.Exercise), new VisitRecord(1, 12, time + TimeSpan.FromMinutes(4), SlideType.Exercise), new VisitRecord(1, 13, time + TimeSpan.FromMinutes(8), SlideType.Quiz), new VisitRecord(1, 14, time + TimeSpan.FromMinutes(100), SlideType.Exercise) }; var median = My_StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise); Assert.AreEqual(2, median, 1e-5); }
public void NoVisits() { var median = My_StatisticsTask.GetMedianTimePerSlide(new List <VisitRecord>(), SlideType.Exercise); Assert.AreEqual(0, median, 1e-5); }