1
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2
|
using System;
|
3
|
using ServerApp.Parser.Parsers;
|
4
|
using System.Collections.Generic;
|
5
|
using ServerApp.Parser.OutputInfo;
|
6
|
using Moq;
|
7
|
using ServerApp.Parser.InputData;
|
8
|
|
9
|
namespace ServerAppFunctionalTests.ParserTests
|
10
|
{
|
11
|
/// <summary>
|
12
|
/// Testing class for LoginParser
|
13
|
/// </summary>
|
14
|
[TestClass]
|
15
|
public class LoginParserTesting
|
16
|
{
|
17
|
|
18
|
#region Login parser
|
19
|
|
20
|
#region Parse days
|
21
|
[TestMethod]
|
22
|
public void ParseLoginDayOne()
|
23
|
{
|
24
|
TagInfo.CreateDictionaries();
|
25
|
|
26
|
string path = "";
|
27
|
List<LogInInstance> data = new List<LogInInstance>();
|
28
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
29
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
30
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "UC", "Učebna", "UC-108", "uc233p02-fav"));
|
31
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
32
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 16, 00, 0), new DateTime(2000, 1, 1, 10, 5, 0), "UC", "Učebna", "LS-108", "ls233p02-fdu"));
|
33
|
|
34
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
35
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
36
|
|
37
|
LogInParser target = new LogInParser(dl.Object);
|
38
|
PrivateObject obj = new PrivateObject(target);
|
39
|
|
40
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
41
|
|
42
|
Assert.AreEqual(2, retVal.Count);
|
43
|
Assert.AreEqual(new ActivityInfo("FDU", 4, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
44
|
Assert.AreEqual(new ActivityInfo("FAV", 6, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
45
|
}
|
46
|
|
47
|
[TestMethod]
|
48
|
public void ParseLoginDayOneFiltering()
|
49
|
{
|
50
|
TagInfo.CreateDictionaries();
|
51
|
|
52
|
string path = "";
|
53
|
List<LogInInstance> data = new List<LogInInstance>();
|
54
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
55
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 6, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
56
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
57
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "UC", "Učebna", "UC-108", "uc233p02-fav"));
|
58
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
59
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 16, 00, 0), new DateTime(2000, 1, 1, 16, 5, 0), "UC", "Učebna", "UC-108", "ls233p02-fdu"));
|
60
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "UC", "Učebna", "UC-108", "ls233p02-fdu"));
|
61
|
|
62
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
63
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
64
|
|
65
|
LogInParser target = new LogInParser(dl.Object);
|
66
|
PrivateObject obj = new PrivateObject(target);
|
67
|
|
68
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1, 16, 0, 0));
|
69
|
|
70
|
Assert.AreEqual(2, retVal.Count);
|
71
|
Assert.AreEqual(new ActivityInfo("FDU", 4, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
72
|
Assert.AreEqual(new ActivityInfo("FAV", 6, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
73
|
}
|
74
|
|
75
|
[TestMethod]
|
76
|
public void ParseLoginDayTwo()
|
77
|
{
|
78
|
TagInfo.CreateDictionaries();
|
79
|
|
80
|
string path = "";
|
81
|
List<LogInInstance> data = new List<LogInInstance>();
|
82
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
83
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
84
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "UC", "Učebna", "UC-108", "uc233p02-fav"));
|
85
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
86
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 16, 00, 0), new DateTime(2000, 1, 1, 16, 5, 0), "UC", "Učebna", "UC-108", "ls233p02-fdu"));
|
87
|
|
88
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
89
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 3, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EU", "Učebna", "EU-108", "uc233p02-fav"));
|
90
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
91
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
92
|
|
93
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
94
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
95
|
|
96
|
LogInParser target = new LogInParser(dl.Object);
|
97
|
PrivateObject obj = new PrivateObject(target);
|
98
|
|
99
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 1, 3, 0, 0, 0));
|
100
|
|
101
|
Assert.AreEqual(4, retVal.Count);
|
102
|
Assert.AreEqual(new ActivityInfo("FDU", 4, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
103
|
Assert.AreEqual(new ActivityInfo("FAV", 6, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
104
|
|
105
|
Assert.AreEqual(new ActivityInfo("FDU", 7, new DateTime(2000, 1, 2, 7, 0, 0), 18 - 7), retVal[2]);
|
106
|
Assert.AreEqual(new ActivityInfo("FEL", 5, new DateTime(2000, 1, 2, 7, 0, 0), 18 - 7), retVal[3]);
|
107
|
}
|
108
|
|
109
|
[TestMethod]
|
110
|
public void ParseLoginDayTwoFiltering()
|
111
|
{
|
112
|
TagInfo.CreateDictionaries();
|
113
|
|
114
|
string path = "";
|
115
|
List<LogInInstance> data = new List<LogInInstance>();
|
116
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
117
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 5, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
118
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
119
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "UC", "Učebna", "UC-108", "uc233p02-fav"));
|
120
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
121
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 16, 00, 0), new DateTime(2000, 1, 1, 16, 5, 0), "UC", "Učebna", "UC-108", "ls233p02-fdu"));
|
122
|
|
123
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 6, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
124
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
125
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 3, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EU", "Učebna", "EU-108", "uc233p02-fav"));
|
126
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
127
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
128
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 19, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
129
|
|
130
|
data.Add(new LogInInstance(new DateTime(2000, 1, 3, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
131
|
data.Add(new LogInInstance(new DateTime(2000, 1, 3, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
132
|
|
133
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
134
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
135
|
|
136
|
LogInParser target = new LogInParser(dl.Object);
|
137
|
PrivateObject obj = new PrivateObject(target);
|
138
|
|
139
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 1, 3, 0, 0, 0));
|
140
|
|
141
|
Assert.AreEqual(4, retVal.Count);
|
142
|
Assert.AreEqual(new ActivityInfo("FDU", 4, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
143
|
Assert.AreEqual(new ActivityInfo("FAV", 6, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
144
|
|
145
|
Assert.AreEqual(new ActivityInfo("FDU", 7, new DateTime(2000, 1, 2, 7, 0, 0), 18 - 7), retVal[2]);
|
146
|
Assert.AreEqual(new ActivityInfo("FEL", 5, new DateTime(2000, 1, 2, 7, 0, 0), 18 - 7), retVal[3]);
|
147
|
}
|
148
|
|
149
|
|
150
|
[TestMethod]
|
151
|
public void ParseLoginDayNone()
|
152
|
{
|
153
|
TagInfo.CreateDictionaries();
|
154
|
|
155
|
string path = "";
|
156
|
List<LogInInstance> data = new List<LogInInstance>();
|
157
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
158
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 5, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
159
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "UC", "Učebna", "UC-108", "uc233p02-fav"));
|
160
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
161
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 16, 00, 0), new DateTime(2000, 1, 1, 16, 5, 0), "UC", "Učebna", "UC-108", "ls233p02-fdu"));
|
162
|
|
163
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
164
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 3, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EU", "Učebna", "EU-108", "uc233p02-fav"));
|
165
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 6, new DateTime(2000, 1, 1, 12, 20, 0), new DateTime(2000, 1, 1, 12, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
166
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 7, new DateTime(2000, 1, 1, 17, 00, 0), new DateTime(2000, 1, 1, 17, 5, 0), "EU", "Učebna", "EU-108", "ls233p02-fdu"));
|
167
|
|
168
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
169
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
170
|
|
171
|
LogInParser target = new LogInParser(dl.Object);
|
172
|
PrivateObject obj = new PrivateObject(target);
|
173
|
|
174
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1, 9, 0, 0));
|
175
|
|
176
|
Assert.AreEqual(0, retVal.Count);
|
177
|
}
|
178
|
|
179
|
[TestMethod]
|
180
|
public void ParseLoginDayEmpty()
|
181
|
{
|
182
|
string path = "";
|
183
|
List<WeatherInstance> data = new List<WeatherInstance>();
|
184
|
|
185
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
186
|
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
187
|
|
188
|
LogInParser target = new LogInParser(dl.Object);
|
189
|
PrivateObject obj = new PrivateObject(target);
|
190
|
|
191
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
192
|
|
193
|
Assert.AreEqual(0, retVal.Count);
|
194
|
}
|
195
|
|
196
|
|
197
|
[TestMethod]
|
198
|
public void ParseLoginDayNull()
|
199
|
{
|
200
|
string path = "";
|
201
|
List<WeatherInstance> data = null;
|
202
|
|
203
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
204
|
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
205
|
|
206
|
LogInParser target = new LogInParser(dl.Object);
|
207
|
PrivateObject obj = new PrivateObject(target);
|
208
|
|
209
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
210
|
|
211
|
Assert.AreEqual(0, retVal.Count);
|
212
|
}
|
213
|
#endregion
|
214
|
|
215
|
#region Parse hours
|
216
|
[TestMethod]
|
217
|
public void ParseLoginEmpty()
|
218
|
{
|
219
|
string path = "";
|
220
|
List<WeatherInstance> data = new List<WeatherInstance>();
|
221
|
|
222
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
223
|
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
224
|
|
225
|
LogInParser target = new LogInParser(dl.Object);
|
226
|
PrivateObject obj = new PrivateObject(target);
|
227
|
|
228
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
229
|
|
230
|
Assert.AreEqual(0, retVal.Count);
|
231
|
}
|
232
|
|
233
|
|
234
|
[TestMethod]
|
235
|
public void ParseLoginNull()
|
236
|
{
|
237
|
string path = "";
|
238
|
List<WeatherInstance> data = null;
|
239
|
|
240
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
241
|
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
242
|
|
243
|
LogInParser target = new LogInParser(dl.Object);
|
244
|
PrivateObject obj = new PrivateObject(target);
|
245
|
|
246
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
247
|
|
248
|
Assert.AreEqual(0, retVal.Count);
|
249
|
}
|
250
|
|
251
|
[TestMethod]
|
252
|
public void ParseLoginHourlyOne()
|
253
|
{
|
254
|
TagInfo.CreateDictionaries();
|
255
|
|
256
|
string path = "";
|
257
|
List<LogInInstance> data = new List<LogInInstance>();
|
258
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
259
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
260
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EL", "Učebna", "UC-108", "uc233p02-fav"));
|
261
|
|
262
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 13, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
263
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 14, 00, 0), new DateTime(2000, 1, 1, 10, 5, 0), "UC", "Učebna", "LS-108", "ls233p02-fdu"));
|
264
|
|
265
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 18, 0, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
266
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 18, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
267
|
|
268
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
269
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
270
|
|
271
|
LogInParser target = new LogInParser(dl.Object);
|
272
|
PrivateObject obj = new PrivateObject(target);
|
273
|
|
274
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
275
|
|
276
|
Assert.AreEqual(5, retVal.Count);
|
277
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[0]);
|
278
|
Assert.AreEqual(new ActivityInfo("FEL", 1, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[1]);
|
279
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[2]);
|
280
|
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[3]);
|
281
|
Assert.AreEqual(new ActivityInfo("FDU", 7, new DateTime(2000, 1, 1, 17, 0, 0), 2), retVal[4]);
|
282
|
}
|
283
|
|
284
|
[TestMethod]
|
285
|
public void ParseLoginDayHourlyMultiple()
|
286
|
{
|
287
|
TagInfo.CreateDictionaries();
|
288
|
|
289
|
string path = "";
|
290
|
List<LogInInstance> data = new List<LogInInstance>();
|
291
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
292
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
293
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EL", "Učebna", "UC-108", "uc233p02-fav"));
|
294
|
|
295
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 13, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
296
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 14, 00, 0), new DateTime(2000, 1, 1, 10, 5, 0), "UC", "Učebna", "LS-108", "ls233p02-fdu"));
|
297
|
|
298
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 18, 0, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
299
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 18, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
300
|
|
301
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
302
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
303
|
|
304
|
LogInParser target = new LogInParser(dl.Object);
|
305
|
PrivateObject obj = new PrivateObject(target);
|
306
|
|
307
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
308
|
|
309
|
Assert.AreEqual(5, retVal.Count);
|
310
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[0]);
|
311
|
Assert.AreEqual(new ActivityInfo("FEL", 1, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[1]);
|
312
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[2]);
|
313
|
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[3]);
|
314
|
Assert.AreEqual(new ActivityInfo("FDU", 7, new DateTime(2000, 1, 2, 17, 0, 0), 2), retVal[4]);
|
315
|
}
|
316
|
|
317
|
[TestMethod]
|
318
|
public void ParseLoginHourlyFiltering()
|
319
|
{
|
320
|
TagInfo.CreateDictionaries();
|
321
|
|
322
|
string path = "";
|
323
|
List<LogInInstance> data = new List<LogInInstance>();
|
324
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
325
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 5, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
326
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 9, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
327
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 10, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EL", "Učebna", "UC-108", "uc233p02-fav"));
|
328
|
|
329
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 13, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
330
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 14, 00, 0), new DateTime(2000, 1, 1, 10, 5, 0), "UC", "Učebna", "LS-108", "ls233p02-fdu"));
|
331
|
|
332
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 18, 0, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
333
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 18, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
334
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 19, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
335
|
|
336
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
337
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
338
|
|
339
|
LogInParser target = new LogInParser(dl.Object);
|
340
|
PrivateObject obj = new PrivateObject(target);
|
341
|
|
342
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
343
|
|
344
|
Assert.AreEqual(5, retVal.Count);
|
345
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[0]);
|
346
|
Assert.AreEqual(new ActivityInfo("FEL", 1, new DateTime(2000, 1, 1, 9, 0, 0), 2), retVal[1]);
|
347
|
Assert.AreEqual(new ActivityInfo("FDU", 2, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[2]);
|
348
|
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 1, 13, 0, 0), 2), retVal[3]);
|
349
|
Assert.AreEqual(new ActivityInfo("FDU", 7, new DateTime(2000, 1, 2, 17, 0, 0), 2), retVal[4]);
|
350
|
}
|
351
|
|
352
|
[TestMethod]
|
353
|
public void ParseLoginHourlyNone()
|
354
|
{
|
355
|
TagInfo.CreateDictionaries();
|
356
|
|
357
|
string path = "";
|
358
|
List<LogInInstance> data = new List<LogInInstance>();
|
359
|
// "01.06.2019 00:00:00"; 2; 4; "10:15"; "11:00"; "LS"; "Učebna"; "LS-234"; "ls233p02-fdu"
|
360
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 3, new DateTime(2000, 1, 1, 5, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
361
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 1, 4, new DateTime(2000, 1, 1, 9, 15, 0), new DateTime(2000, 1, 1, 11, 0, 0), "EL", "Učebna", "UC-108", "uc233p02-fav"));
|
362
|
|
363
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 19, 0, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
364
|
data.Add(new LogInInstance(new DateTime(2000, 1, 1, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 19, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "UC", "Učebna", "LS-108", "ls233p02-fdu"));
|
365
|
|
366
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 2, 6, new DateTime(2000, 1, 1, 18, 0, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
367
|
data.Add(new LogInInstance(new DateTime(2000, 1, 2, 0, 0, 0), 5, 7, new DateTime(2000, 1, 1, 18, 20, 0), new DateTime(2000, 1, 1, 10, 5, 0), "LS", "Učebna", "LS-108", "ls233p02-fdu"));
|
368
|
|
369
|
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
370
|
dl.Setup(m => m.LoadLoginFile(path)).Returns(data);
|
371
|
|
372
|
LogInParser target = new LogInParser(dl.Object);
|
373
|
PrivateObject obj = new PrivateObject(target);
|
374
|
|
375
|
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 10, 0, 0), new DateTime(2000, 1, 2, 10, 0, 0));
|
376
|
|
377
|
Assert.AreEqual(0, retVal.Count);
|
378
|
}
|
379
|
#endregion
|
380
|
|
381
|
#endregion
|
382
|
|
383
|
}
|
384
|
}
|