-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatisticsTests.cs
75 lines (70 loc) · 2.26 KB
/
StatisticsTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using NUnit.Framework;
namespace linq_slideviews
{
[TestFixture]
public class StatisticsTests
{
[Test]
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 = StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise);
Assert.AreEqual(2, median, 1e-5);
}
[Test]
public void NoVisits()
{
var median = StatisticsTask.GetMedianTimePerSlide(new List<VisitRecord>(), SlideType.Exercise);
Assert.AreEqual(0, median, 1e-5);
}
[Test]
public void NoMatchingVisits()
{
var time = DateTime.Now;
var visits = new List<VisitRecord>
{
new VisitRecord(1, 10, time, SlideType.Quiz),
new VisitRecord(1, 11, time + TimeSpan.FromMinutes(2), SlideType.Quiz)
};
var median = StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise);
Assert.AreEqual(0, median, 1e-5);
}
[Test]
public void TwoUsers()
{
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(2, 13, time + TimeSpan.FromMinutes(100), SlideType.Exercise),
new VisitRecord(2, 14, time + TimeSpan.FromMinutes(110), SlideType.Exercise),
new VisitRecord(2, 15, time + TimeSpan.FromMinutes(120), SlideType.Exercise)
};
var median = StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise);
Assert.AreEqual(10, median, 1e-5);
}
[Test]
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 = StatisticsTask.GetMedianTimePerSlide(visits, SlideType.Exercise);
Assert.AreEqual(2, median, 1e-5);
}
}
}