|
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 |
// 1h
|
|
10 |
// 0.5h to edit parsers
|
|
11 |
|
|
12 |
namespace TestProject
|
|
13 |
{
|
|
14 |
|
|
15 |
[TestClass]
|
|
16 |
public class TestingParser
|
|
17 |
{
|
|
18 |
[TestMethod]
|
|
19 |
public void AbstactClassTest()
|
|
20 |
{
|
|
21 |
IDataParser p = new DataParser(null);
|
|
22 |
List<ActivityInfo> aa = p.AttendanceList;
|
|
23 |
List<WeatherInfo> wa = p.WeatherList;
|
|
24 |
|
|
25 |
DataParser pp = (DataParser)p;
|
|
26 |
List<ActivityInfo> ap = pp.AttendanceList;
|
|
27 |
List<WeatherInfo> wp = pp.WeatherList;
|
|
28 |
|
|
29 |
Assert.AreEqual(aa, ap);
|
|
30 |
Assert.AreEqual(wa, wp);
|
|
31 |
}
|
|
32 |
|
|
33 |
// ------------------------------------ MERGE LISTS -------------------------------------
|
|
34 |
|
|
35 |
#region Merge lists
|
|
36 |
[TestMethod]
|
|
37 |
public void MergeListsNull()
|
|
38 |
{
|
|
39 |
DataParser target = new DataParser(null);
|
|
40 |
PrivateObject obj = new PrivateObject(target);
|
|
41 |
|
|
42 |
List<ActivityInfo> jis = null;
|
|
43 |
List<ActivityInfo> pc = null;
|
|
44 |
|
|
45 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
46 |
Assert.AreEqual(0, retVal.Count);
|
|
47 |
}
|
|
48 |
|
|
49 |
[TestMethod]
|
|
50 |
public void MergeListsJisNull()
|
|
51 |
{
|
|
52 |
DataParser target = new DataParser(null);
|
|
53 |
PrivateObject obj = new PrivateObject(target);
|
|
54 |
|
|
55 |
List<ActivityInfo> jis = null;
|
|
56 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
57 |
|
|
58 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
59 |
Assert.AreEqual(pc, retVal);
|
|
60 |
}
|
|
61 |
|
|
62 |
[TestMethod]
|
|
63 |
public void MergeListsPcNull()
|
|
64 |
{
|
|
65 |
DataParser target = new DataParser(null);
|
|
66 |
PrivateObject obj = new PrivateObject(target);
|
|
67 |
|
|
68 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
69 |
List<ActivityInfo> pc = null;
|
|
70 |
|
|
71 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
72 |
Assert.AreEqual(jis, retVal);
|
|
73 |
}
|
|
74 |
|
|
75 |
[TestMethod]
|
|
76 |
public void MergeListsOneNoOverlap()
|
|
77 |
{
|
|
78 |
DataParser target = new DataParser(null);
|
|
79 |
PrivateObject obj = new PrivateObject(target);
|
|
80 |
|
|
81 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
82 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
83 |
|
|
84 |
jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
85 |
pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 18, 0, 0), 3));
|
|
86 |
|
|
87 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
88 |
|
|
89 |
Assert.AreEqual(2, retVal.Count);
|
|
90 |
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[0]);
|
|
91 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 18, 0, 0), 3), retVal[1]);
|
|
92 |
}
|
|
93 |
|
|
94 |
[TestMethod]
|
|
95 |
public void MergeListsOneOverlap()
|
|
96 |
{
|
|
97 |
DataParser target = new DataParser(null);
|
|
98 |
PrivateObject obj = new PrivateObject(target);
|
|
99 |
|
|
100 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
101 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
102 |
|
|
103 |
jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
104 |
pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
105 |
|
|
106 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
107 |
|
|
108 |
Assert.AreEqual(1, retVal.Count);
|
|
109 |
Assert.AreEqual(new ActivityInfo("FAV", 8, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[0]);
|
|
110 |
}
|
|
111 |
|
|
112 |
[TestMethod]
|
|
113 |
public void MergeListsTwoNoOverlap()
|
|
114 |
{
|
|
115 |
DataParser target = new DataParser(null);
|
|
116 |
PrivateObject obj = new PrivateObject(target);
|
|
117 |
|
|
118 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
119 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
120 |
|
|
121 |
jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3));
|
|
122 |
jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
123 |
pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
|
|
124 |
pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 18, 0, 0), 3));
|
|
125 |
|
|
126 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
127 |
|
|
128 |
Assert.AreEqual(4, retVal.Count);
|
|
129 |
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3), retVal[0]);
|
|
130 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
|
|
131 |
Assert.AreEqual(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
|
|
132 |
Assert.AreEqual(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 18, 0, 0), 3), retVal[3]);
|
|
133 |
}
|
|
134 |
|
|
135 |
[TestMethod]
|
|
136 |
public void MergeListsTwoOverlap()
|
|
137 |
{
|
|
138 |
DataParser target = new DataParser(null);
|
|
139 |
PrivateObject obj = new PrivateObject(target);
|
|
140 |
|
|
141 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
142 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
143 |
|
|
144 |
jis.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3));
|
|
145 |
jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
146 |
pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
|
|
147 |
pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
148 |
|
|
149 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
150 |
|
|
151 |
Assert.AreEqual(3, retVal.Count);
|
|
152 |
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 1, 1, 9, 0, 0), 3), retVal[0]);
|
|
153 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
|
|
154 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
|
|
155 |
}
|
|
156 |
|
|
157 |
[TestMethod]
|
|
158 |
public void MergeListsMultiple()
|
|
159 |
{
|
|
160 |
DataParser target = new DataParser(null);
|
|
161 |
PrivateObject obj = new PrivateObject(target);
|
|
162 |
|
|
163 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
164 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
165 |
|
|
166 |
jis.Add(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 10, 9, 0, 0), 3));
|
|
167 |
jis.Add(new ActivityInfo("FAV", 1, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
168 |
jis.Add(new ActivityInfo("FDU", 3, new DateTime(2001, 4, 1, 15, 0, 0), 3));
|
|
169 |
|
|
170 |
pc.Add(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3));
|
|
171 |
pc.Add(new ActivityInfo("FAV", 2, new DateTime(2001, 1, 1, 15, 0, 0), 3));
|
|
172 |
pc.Add(new ActivityInfo("FAV", 5, new DateTime(2001, 4, 1, 15, 0, 0), 3));
|
|
173 |
|
|
174 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
|
|
175 |
|
|
176 |
Assert.AreEqual(5, retVal.Count);
|
|
177 |
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2000, 1, 10, 9, 0, 0), 3), retVal[0]);
|
|
178 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 12, 0, 0), 3), retVal[1]);
|
|
179 |
Assert.AreEqual(new ActivityInfo("FAV", 3, new DateTime(2001, 1, 1, 15, 0, 0), 3), retVal[2]);
|
|
180 |
Assert.AreEqual(new ActivityInfo("FDU", 3, new DateTime(2001, 4, 1, 15, 0, 0), 3), retVal[3]);
|
|
181 |
Assert.AreEqual(new ActivityInfo("FAV", 5, new DateTime(2001, 4, 1, 15, 0, 0), 3), retVal[4]);
|
|
182 |
}
|
|
183 |
#endregion
|
|
184 |
|
|
185 |
// ------------------------------ WEATHER PARSER ----------------------------------------
|
|
186 |
|
|
187 |
#region Weather parser
|
|
188 |
|
|
189 |
#region Parse days
|
|
190 |
[TestMethod]
|
|
191 |
public void ParseWeatherDayOne()
|
|
192 |
{
|
|
193 |
string path = "";
|
|
194 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
195 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast)/1000));
|
|
196 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 7, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast)/1000));
|
|
197 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 10, 3, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast)/1000));
|
|
198 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 12, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast)/1000));
|
|
199 |
|
|
200 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
201 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
202 |
|
|
203 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
204 |
PrivateObject obj = new PrivateObject(target);
|
|
205 |
|
|
206 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
207 |
|
|
208 |
Assert.AreEqual(1, retVal.Count);
|
|
209 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 8, 50, 1.25, 10_000, 18-7), retVal[0]);
|
|
210 |
}
|
|
211 |
|
|
212 |
[TestMethod]
|
|
213 |
public void ParseWeatherDayOneFiltering()
|
|
214 |
{
|
|
215 |
string path = "";
|
|
216 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
217 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
218 |
|
|
219 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 7, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
220 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 10, 3, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
221 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 12, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
222 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 13, 0, 0), 12, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
223 |
|
|
224 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 16, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
225 |
|
|
226 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
227 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
228 |
|
|
229 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
230 |
PrivateObject obj = new PrivateObject(target);
|
|
231 |
|
|
232 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
233 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
234 |
|
|
235 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1, 9, 0, 0), new DateTime(2000, 1, 1, 15, 0, 0));
|
|
236 |
|
|
237 |
Assert.AreEqual(1, retVal.Count);
|
|
238 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 9.75, 25, 1.75, 10_000, 18 - 7), retVal[0]);
|
|
239 |
}
|
|
240 |
|
|
241 |
[TestMethod]
|
|
242 |
public void ParseWeatherDayTwo()
|
|
243 |
{
|
|
244 |
string path = "";
|
|
245 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
246 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
247 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 10, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
248 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 3, 3, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
249 |
|
|
250 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 12, 0, 0), 5, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
251 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
252 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
253 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 16, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
254 |
|
|
255 |
|
|
256 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
257 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
258 |
|
|
259 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
260 |
PrivateObject obj = new PrivateObject(target);
|
|
261 |
|
|
262 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
263 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
264 |
|
|
265 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
266 |
|
|
267 |
Assert.AreEqual(2, retVal.Count);
|
|
268 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 6, 100, 1, 10_000, 18-7), retVal[0]);
|
|
269 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 7, 0, 0), 10, 25, 2, 10_000, 18-7), retVal[1]);
|
|
270 |
}
|
|
271 |
|
|
272 |
[TestMethod]
|
|
273 |
public void ParseWeatherDayTwoFiltering()
|
|
274 |
{
|
|
275 |
string path = "";
|
|
276 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
277 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
278 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 10, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
279 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 3, 3, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
280 |
|
|
281 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 12, 0, 0), 5, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
282 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
283 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
284 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 16, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
285 |
|
|
286 |
|
|
287 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
288 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
289 |
|
|
290 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
291 |
PrivateObject obj = new PrivateObject(target);
|
|
292 |
|
|
293 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
294 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
295 |
|
|
296 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2000, 1, 1, 11, 0, 0));
|
|
297 |
|
|
298 |
Assert.AreEqual(1, retVal.Count);
|
|
299 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 6, 100, 1, 10_000, 18 - 7), retVal[0]);
|
|
300 |
//Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 7, 0, 0), 10, 25, 2, 10_000, 18 - 7), retVal[1]);
|
|
301 |
}
|
|
302 |
#endregion
|
|
303 |
|
|
304 |
#region Parse hours
|
|
305 |
[TestMethod]
|
|
306 |
public void ParseWeatherHourOne()
|
|
307 |
{
|
|
308 |
string path = "";
|
|
309 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
310 |
|
|
311 |
// day 1
|
|
312 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
313 |
|
|
314 |
|
|
315 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
316 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
317 |
|
|
318 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
319 |
PrivateObject obj = new PrivateObject(target);
|
|
320 |
|
|
321 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
322 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
323 |
|
|
324 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
|
325 |
|
|
326 |
Assert.AreEqual(1, retVal.Count);
|
|
327 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 5, 100, 0, (double)0, 2), retVal[0]);
|
|
328 |
}
|
|
329 |
|
|
330 |
[TestMethod]
|
|
331 |
public void ParseWeatherHourMultiple()
|
|
332 |
{
|
|
333 |
string path = "";
|
|
334 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
335 |
|
|
336 |
// day 1
|
|
337 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
338 |
|
|
339 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 10, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
340 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 3, 3, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
341 |
|
|
342 |
// day 2
|
|
343 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 12, 0, 0), 5, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Sunny) / 1000));
|
|
344 |
|
|
345 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
346 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
347 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 15, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
348 |
|
|
349 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 16, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
350 |
|
|
351 |
|
|
352 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
353 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
354 |
|
|
355 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
356 |
PrivateObject obj = new PrivateObject(target);
|
|
357 |
|
|
358 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
359 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
360 |
|
|
361 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
|
|
362 |
|
|
363 |
Assert.AreEqual(5, retVal.Count);
|
|
364 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 5, 100, 0, (double)0, 2), retVal[0]);
|
|
365 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 9, 0, 0), 6.5, 100, 1.5, 10_000, 2), retVal[1]);
|
|
366 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 11, 0, 0), 5, 0, 2, 60_000, 2), retVal[2]);
|
|
367 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 13, 0, 0), 10, 25, 2, 10_000, 2), retVal[3]);
|
|
368 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 15, 0, 0), 15, 40, 2, 10_000, 2), retVal[4]);
|
|
369 |
}
|
|
370 |
|
|
371 |
|
|
372 |
[TestMethod]
|
|
373 |
public void ParseWeatherHourFiltering()
|
|
374 |
{
|
|
375 |
string path = "";
|
|
376 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
377 |
|
|
378 |
// day 1
|
|
379 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
380 |
|
|
381 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 10, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
382 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 10, 0, 0), 3, 3, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
383 |
|
|
384 |
// day 2
|
|
385 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 12, 0, 0), 5, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Sunny) / 1000));
|
|
386 |
|
|
387 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
388 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
389 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 13, 15, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
390 |
|
|
391 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 16, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
392 |
|
|
393 |
|
|
394 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
395 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
396 |
|
|
397 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
398 |
PrivateObject obj = new PrivateObject(target);
|
|
399 |
|
|
400 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
401 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
402 |
|
|
403 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 9, 0, 0), new DateTime(2000, 2, 1, 13, 0, 0));
|
|
404 |
|
|
405 |
Assert.AreEqual(3, retVal.Count);
|
|
406 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 9, 0, 0), 6.5, 100, 1.5, 10_000, 2), retVal[0]);
|
|
407 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 11, 0, 0), 5, 0, 2, 60_000, 2), retVal[1]);
|
|
408 |
Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 13, 0, 0), 10, 33, 2, 10_000, 2), retVal[2]);
|
|
409 |
}
|
|
410 |
|
|
411 |
[TestMethod]
|
|
412 |
public void ParseWeatherHourNone()
|
|
413 |
{
|
|
414 |
string path = "";
|
|
415 |
List<WeatherInstance> data = new List<WeatherInstance>();
|
|
416 |
|
|
417 |
// day 1
|
|
418 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 8, 0, 0), 5, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
419 |
data.Add(new WeatherInstance(new DateTime(2000, 1, 1, 9, 0, 0), 10, 0, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Dark) / 1000));
|
|
420 |
|
|
421 |
// day 2
|
|
422 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 16, 0, 0), 10, 2, 0, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
423 |
data.Add(new WeatherInstance(new DateTime(2000, 2, 1, 17, 0, 0), 15, 2, 1, ValueToConditions.TransferConditionsToLux(WeatherConditions.Overcast) / 1000));
|
|
424 |
|
|
425 |
|
|
426 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
427 |
dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
|
|
428 |
|
|
429 |
WeatherParser target = new WeatherParser(dl.Object);
|
|
430 |
PrivateObject obj = new PrivateObject(target);
|
|
431 |
|
|
432 |
List<ActivityInfo> jis = new List<ActivityInfo>();
|
|
433 |
List<ActivityInfo> pc = new List<ActivityInfo>();
|
|
434 |
|
|
435 |
List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 10, 0, 0), new DateTime(2000, 2, 1, 15, 0, 0));
|
|
436 |
|
|
437 |
Assert.AreEqual(0, retVal.Count);
|
|
438 |
}
|
|
439 |
#endregion
|
|
440 |
|
|
441 |
#endregion
|
|
442 |
|
|
443 |
#region Jis parser
|
|
444 |
|
|
445 |
#region Parse days
|
|
446 |
[TestMethod]
|
|
447 |
public void ParseJisDayOne()
|
|
448 |
{
|
|
449 |
TagInfo.CreateDictionaries();
|
|
450 |
|
|
451 |
string path = "";
|
|
452 |
List<JisInstance> data = new List<JisInstance>();
|
|
453 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
454 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 10, 0, 0), 3));
|
|
455 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
456 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
457 |
|
|
458 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
459 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
460 |
|
|
461 |
JisParser target = new JisParser(dl.Object);
|
|
462 |
PrivateObject obj = new PrivateObject(target);
|
|
463 |
|
|
464 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
465 |
|
|
466 |
Assert.AreEqual(2, retVal.Count);
|
|
467 |
Assert.AreEqual(new ActivityInfo("MENZA", 3, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
|
468 |
Assert.AreEqual(new ActivityInfo("KARMA", 5, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
|
469 |
}
|
|
470 |
|
|
471 |
[TestMethod]
|
|
472 |
public void ParseJisDayOneFiltering()
|
|
473 |
{
|
|
474 |
TagInfo.CreateDictionaries();
|
|
475 |
|
|
476 |
string path = "";
|
|
477 |
List<JisInstance> data = new List<JisInstance>();
|
|
478 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 6, 0, 0), 2));
|
|
479 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
480 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 10, 0, 0), 3));
|
|
481 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
482 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
483 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 17, 0, 0), 2));
|
|
484 |
|
|
485 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
486 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
487 |
|
|
488 |
JisParser target = new JisParser(dl.Object);
|
|
489 |
PrivateObject obj = new PrivateObject(target);
|
|
490 |
|
|
491 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 1, 1, 16, 0, 0));
|
|
492 |
|
|
493 |
Assert.AreEqual(2, retVal.Count);
|
|
494 |
Assert.AreEqual(new ActivityInfo("MENZA", 3, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
|
495 |
Assert.AreEqual(new ActivityInfo("KARMA", 5, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
|
496 |
}
|
|
497 |
|
|
498 |
[TestMethod]
|
|
499 |
public void ParseJisDayTwo()
|
|
500 |
{
|
|
501 |
TagInfo.CreateDictionaries();
|
|
502 |
|
|
503 |
string path = "";
|
|
504 |
List<JisInstance> data = new List<JisInstance>();
|
|
505 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
506 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 10, 0, 0), 3));
|
|
507 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
508 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
509 |
|
|
510 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 2, 1, 8, 0, 0), 8));
|
|
511 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 2, 1, 12, 0, 0), 2));
|
|
512 |
data.Add(new JisInstance("A2", new DateTime(2000, 2, 1, 16, 0, 0), 1));
|
|
513 |
|
|
514 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
515 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
516 |
|
|
517 |
JisParser target = new JisParser(dl.Object);
|
|
518 |
PrivateObject obj = new PrivateObject(target);
|
|
519 |
|
|
520 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 2, 1, 16, 0, 0));
|
|
521 |
|
|
522 |
Assert.AreEqual(4, retVal.Count);
|
|
523 |
Assert.AreEqual(new ActivityInfo("MENZA", 3, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
|
524 |
Assert.AreEqual(new ActivityInfo("KARMA", 5, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
|
525 |
|
|
526 |
Assert.AreEqual(new ActivityInfo("MENZA", 10, new DateTime(2000, 2, 1, 7, 0, 0), 18 - 7), retVal[2]);
|
|
527 |
Assert.AreEqual(new ActivityInfo("KARMA", 1, new DateTime(2000, 2, 1, 7, 0, 0), 18 - 7), retVal[3]);
|
|
528 |
}
|
|
529 |
|
|
530 |
[TestMethod]
|
|
531 |
public void ParseJisDayTwoFiltering()
|
|
532 |
{
|
|
533 |
TagInfo.CreateDictionaries();
|
|
534 |
|
|
535 |
string path = "";
|
|
536 |
List<JisInstance> data = new List<JisInstance>();
|
|
537 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 6, 0, 0), 2));
|
|
538 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
539 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 10, 0, 0), 3));
|
|
540 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
541 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
542 |
|
|
543 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 2, 1, 8, 0, 0), 8));
|
|
544 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 2, 1, 12, 0, 0), 2));
|
|
545 |
data.Add(new JisInstance("A2", new DateTime(2000, 2, 1, 16, 0, 0), 1));
|
|
546 |
data.Add(new JisInstance("A2", new DateTime(2000, 2, 1, 17, 0, 0), 2));
|
|
547 |
|
|
548 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
549 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
550 |
|
|
551 |
JisParser target = new JisParser(dl.Object);
|
|
552 |
PrivateObject obj = new PrivateObject(target);
|
|
553 |
|
|
554 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2000, 2, 1, 16, 0, 0));
|
|
555 |
|
|
556 |
Assert.AreEqual(4, retVal.Count);
|
|
557 |
Assert.AreEqual(new ActivityInfo("MENZA", 3, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[0]);
|
|
558 |
Assert.AreEqual(new ActivityInfo("KARMA", 5, new DateTime(2000, 1, 1, 7, 0, 0), 18 - 7), retVal[1]);
|
|
559 |
|
|
560 |
Assert.AreEqual(new ActivityInfo("MENZA", 10, new DateTime(2000, 2, 1, 7, 0, 0), 18 - 7), retVal[2]);
|
|
561 |
Assert.AreEqual(new ActivityInfo("KARMA", 1, new DateTime(2000, 2, 1, 7, 0, 0), 18 - 7), retVal[3]);
|
|
562 |
}
|
|
563 |
|
|
564 |
|
|
565 |
[TestMethod]
|
|
566 |
public void ParseJisDayNone()
|
|
567 |
{
|
|
568 |
TagInfo.CreateDictionaries();
|
|
569 |
|
|
570 |
string path = "";
|
|
571 |
List<JisInstance> data = new List<JisInstance>();
|
|
572 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
573 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 10, 0, 0), 3));
|
|
574 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
575 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
576 |
|
|
577 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 2, 15, 0, 0), 2));
|
|
578 |
|
|
579 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
580 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
581 |
|
|
582 |
JisParser target = new JisParser(dl.Object);
|
|
583 |
PrivateObject obj = new PrivateObject(target);
|
|
584 |
|
|
585 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 3), new DateTime(2001, 1, 1));
|
|
586 |
|
|
587 |
Assert.AreEqual(0, retVal.Count);
|
|
588 |
}
|
|
589 |
#endregion
|
|
590 |
|
|
591 |
#region Parse hours
|
|
592 |
[TestMethod]
|
|
593 |
public void ParseJisHourlyOne()
|
|
594 |
{
|
|
595 |
TagInfo.CreateDictionaries();
|
|
596 |
|
|
597 |
string path = "";
|
|
598 |
List<JisInstance> data = new List<JisInstance>();
|
|
599 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
600 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 0, 0), 3));
|
|
601 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 15, 0), 3));
|
|
602 |
|
|
603 |
/*
|
|
604 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 5));
|
|
605 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 12, 0, 0), 1));
|
|
606 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 15, 0, 0), 2));
|
|
607 |
*/
|
|
608 |
|
|
609 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
610 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
611 |
|
|
612 |
JisParser target = new JisParser(dl.Object);
|
|
613 |
PrivateObject obj = new PrivateObject(target);
|
|
614 |
|
|
615 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
616 |
|
|
617 |
Assert.AreEqual(2, retVal.Count);
|
|
618 |
Assert.AreEqual(new ActivityInfo("MENZA", 2, new DateTime(2000, 1, 1, 7, 0, 0), 2), retVal[0]);
|
|
619 |
Assert.AreEqual(new ActivityInfo("KARMA", 6, new DateTime(2000, 1, 1, 7, 0, 0), 2), retVal[1]);
|
|
620 |
}
|
|
621 |
|
|
622 |
[TestMethod]
|
|
623 |
public void ParseJisDayHourlyMultiple()
|
|
624 |
{
|
|
625 |
TagInfo.CreateDictionaries();
|
|
626 |
|
|
627 |
string path = "";
|
|
628 |
List<JisInstance> data = new List<JisInstance>();
|
|
629 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 7, 0, 0), 2));
|
|
630 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 0, 0), 3));
|
|
631 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 15, 0), 3));
|
|
632 |
|
|
633 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 11, 0, 0), 5));
|
|
634 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 11, 10, 0), 1));
|
|
635 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 11, 20, 0), 2));
|
|
636 |
|
|
637 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
638 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
639 |
|
|
640 |
JisParser target = new JisParser(dl.Object);
|
|
641 |
PrivateObject obj = new PrivateObject(target);
|
|
642 |
|
|
643 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
644 |
|
|
645 |
Assert.AreEqual(4, retVal.Count);
|
|
646 |
Assert.AreEqual(new ActivityInfo("MENZA", 2, new DateTime(2000, 1, 1, 7, 0, 0), 2), retVal[0]);
|
|
647 |
Assert.AreEqual(new ActivityInfo("KARMA", 6, new DateTime(2000, 1, 1, 7, 0, 0), 2), retVal[1]);
|
|
648 |
Assert.AreEqual(new ActivityInfo("MENZA", 6, new DateTime(2000, 1, 1, 11, 0, 0), 2), retVal[2]);
|
|
649 |
Assert.AreEqual(new ActivityInfo("KARMA", 2, new DateTime(2000, 1, 1, 11, 0, 0), 2), retVal[3]);
|
|
650 |
}
|
|
651 |
|
|
652 |
[TestMethod]
|
|
653 |
public void ParseJisHourlyNone()
|
|
654 |
{
|
|
655 |
TagInfo.CreateDictionaries();
|
|
656 |
|
|
657 |
string path = "";
|
|
658 |
List<JisInstance> data = new List<JisInstance>();
|
|
659 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 3, 0, 0), 2));
|
|
660 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 4, 0, 0), 3));
|
|
661 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 5, 15, 0), 3));
|
|
662 |
|
|
663 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 19, 0, 0), 5));
|
|
664 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 19, 10, 0), 1));
|
|
665 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 19, 20, 0), 2));
|
|
666 |
|
|
667 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
668 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
669 |
|
|
670 |
JisParser target = new JisParser(dl.Object);
|
|
671 |
PrivateObject obj = new PrivateObject(target);
|
|
672 |
|
|
673 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
674 |
|
|
675 |
Assert.AreEqual(0, retVal.Count);
|
|
676 |
}
|
|
677 |
|
|
678 |
[TestMethod]
|
|
679 |
public void ParseJisHourlyFiltering()
|
|
680 |
{
|
|
681 |
TagInfo.CreateDictionaries();
|
|
682 |
|
|
683 |
string path = "";
|
|
684 |
List<JisInstance> data = new List<JisInstance>();
|
|
685 |
data.Add(new JisInstance("MenzaKL-vydej", new DateTime(2000, 1, 1, 6, 0, 0), 2));
|
|
686 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 0, 0), 3));
|
|
687 |
data.Add(new JisInstance("A2-Hlavni vchod", new DateTime(2000, 1, 1, 8, 15, 0), 3));
|
|
688 |
|
|
689 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 11, 0, 0), 5));
|
|
690 |
data.Add(new JisInstance("Menza4-kasa5", new DateTime(2000, 1, 1, 18, 10, 0), 1));
|
|
691 |
data.Add(new JisInstance("A1", new DateTime(2000, 1, 1, 19, 20, 0), 2));
|
|
692 |
|
|
693 |
Mock<IDataLoader> dl = new Mock<IDataLoader>();
|
|
694 |
dl.Setup(m => m.LoadJisFile(path)).Returns(data);
|
|
695 |
|
|
696 |
JisParser target = new JisParser(dl.Object);
|
|
697 |
PrivateObject obj = new PrivateObject(target);
|
|
698 |
|
|
699 |
List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
|
|
700 |
|
|
701 |
Assert.AreEqual(3, retVal.Count);
|
|
702 |
Assert.AreEqual(new ActivityInfo("KARMA", 6, new DateTime(2000, 1, 1, 7, 0, 0), 2), retVal[0]);
|
|
703 |
Assert.AreEqual(new ActivityInfo("MENZA", 5, new DateTime(2000, 1, 1, 11, 0, 0), 2), retVal[1]);
|
|
704 |
Assert.AreEqual(new ActivityInfo("MENZA", 1, new DateTime(2000, 1, 1, 17, 0, 0), 2), retVal[2]);
|
|
705 |
}
|
|
706 |
|
|
707 |
#endregion
|
|
708 |
|
|
709 |
#endregion
|
|
710 |
}
|
|
711 |
}
|
re #8933 Testing DataParser, JisParser and WeatherParser