Projekt

Obecné

Profil

« Předchozí | Další » 

Revize a53b1de8

Přidáno uživatelem Alex Konig před téměř 4 roky(ů)

re #8933 Testing DataParser, JisParser and WeatherParser

Zobrazit rozdíly:

Server/ServerApp/DataDownload/DataDownloader.cs
388 388
			if (startDate == null || endDate == null)
389 389
				return GetData(subDirectory);
390 390

  
391

  
392 391
			string[] files = Directory.GetFiles(subDirectory);
393 392
			List<string> found00Files = new List<string>();
394 393
			List<string> relevantFiles = new List<string>();
Server/ServerApp/Parser/InputData/CsvDataLoader.cs
40 40
        public List<JisInstance> LoadJisFile(string pathToFile)
41 41
        {
42 42
            var lines = LoadCsv(pathToFile);
43
            if (lines == null)
44
                return null;
45

  
43 46
            List<JisInstance> list = new List<JisInstance>();
44 47

  
45 48
            if (lines == null)
......
75 78
        public List<LogInInstance> LoadLoginFile(string pathToFile)
76 79
        {
77 80
            var lines = LoadCsv(pathToFile);
81
            if (lines == null)
82
                return null;
83

  
78 84
            List<LogInInstance> list = new List<LogInInstance>();
79 85

  
80 86
            if (lines == null)
......
120 126
        public List<WeatherInstance> LoadWeatherFile(string pathToFile)
121 127
        {
122 128
            var lines = LoadCsv(pathToFile);
129
            if (lines == null)
130
                return null;
131

  
123 132
            List<WeatherInstance> list = new List<WeatherInstance>();
124 133

  
125 134
            if (lines == null)
Server/ServerApp/Parser/InputData/IDataLoader.cs
10 10
    /// Interface that every DataLoader should implement
11 11
    /// </summary>
12 12
    /// <author>A. Konig</author>
13
    interface IDataLoader
13
    public interface IDataLoader
14 14
    {
15 15
        /// <summary>
16 16
        /// Load jis data from file
Server/ServerApp/Parser/InputData/JisInstance.cs
18 18
    ///     [place tag];[date time];[amount]
19 19
    /// </summary>
20 20
    /// <author>A. Konig</author>
21
    class JisInstance
21
    public class JisInstance
22 22
    {
23 23
        /// <summary> Place tag  </summary>
24 24
        // index 0
Server/ServerApp/Parser/InputData/LogInInstance.cs
25 25
    ///     [datum];[amount];[lesson];[lesson start];[lesson end];[building];[room type];[room];[hostname]
26 26
    /// </summary>
27 27
    /// <author>A. Konig</author>
28
    class LogInInstance
28
    public class LogInInstance
29 29
    {
30 30
        /// <summary> Date time </summary>
31 31
        // index 0
Server/ServerApp/Parser/InputData/WeatherInstance.cs
14 14
    ///     [date time];[temperature];[wind];[rain];[luminance]
15 15
    /// </summary>
16 16
    /// <author>A. Konig</author>
17
    class WeatherInstance
17
    public class WeatherInstance
18 18
    {
19 19
        /// <summary> Date and time </summary>
20 20
        // index 0
......
48 48
            this.rain = rain;
49 49
            this.lum = lum;
50 50
        }
51

  
52
        /// <summary>
53
        /// Eqquals
54
        /// </summary>
55
        /// <param name="obj"> Other object </param>
56
        /// <returns></returns>
57
        public override bool Equals(object obj)
58
        {
59
            WeatherInstance other = (WeatherInstance) obj;
60

  
61
            if (dateTime == other.dateTime && temp == other.temp && wind == other.wind && rain == other.rain && lum == other.lum)
62
                return true;
63

  
64
            return false;
65
        }
51 66
    }
52 67
}
Server/ServerApp/Parser/OutputInfo/ActivityInfo.cs
45 45
        {
46 46
            return $"{startTime} \t {building} \t {amount}";
47 47
        }
48

  
49

  
50
        /// <summary>
51
        /// Compares object to other instance
52
        /// </summary>
53
        /// <param name="obj"></param>
54
        /// <returns></returns>
55
        public override bool Equals(object obj)
56
        {
57
            ActivityInfo other = (ActivityInfo)obj;
58

  
59
            if (building == other.building && amount == other.amount && startTime == other.startTime && intervalLength == other.intervalLength)
60
                return true;
61

  
62
            return false;
63
        }
48 64
    }
49 65
}
Server/ServerApp/Parser/OutputInfo/ValueToConditions.cs
35 35
        /// </summary>
36 36
        /// <param name="condition">Weather conditions</param>
37 37
        /// <returns>Lux value</returns>
38
        internal static double TransferConditionsToLux(WeatherConditions condition)
38
        public static double TransferConditionsToLux(WeatherConditions condition)
39 39
        {
40 40
            if (condition == WeatherConditions.Sunny)
41 41
                return 60_000;
Server/ServerApp/Parser/OutputInfo/WeatherInfo.cs
85 85
            return $"{startTime} \t {temp}°C \t {rain}% \t {wind}m/s \t {condition.ToString()} \t {lum}";
86 86
        }
87 87

  
88
        /// <summary>
89
        /// Eqquals
90
        /// </summary>
91
        /// <param name="obj"> Other object </param>
92
        /// <returns></returns>
93
        public override bool Equals(object obj)
94
        {
95
            WeatherInfo other = (WeatherInfo) obj;
96

  
97
            if (startTime == other.startTime && temp == other.temp && wind == other.wind && rain == other.rain && condition == other.condition)
98
                return true;
99

  
100
            return false;
101
        }
88 102
    }
89 103
}
Server/ServerApp/Parser/Parsers/DataParser.cs
34 34
        /// <summary> ActivityInfo representing login activity</summary>
35 35
        List<ActivityInfo> loginList;
36 36

  
37

  
38 37
        /// <summary>
39 38
        /// Constructor
40 39
        /// </summary>
......
70 69
            string pathLogIn = downloader.DataSubDirectories[DataType.STROJE];
71 70

  
72 71
            // get all files that should be parsed
73
            Date start = null;
74
            Date end = null;
75
            if (startTime != null || endTime != null)
72
            Date start = new Date((uint)startTime.Month, (uint)startTime.Year);
73
            Date end = new Date((uint)endTime.Month, (uint)endTime.Year);
74
            if (startTime == DateTime.MinValue || endTime == DateTime.MaxValue)
76 75
            {
77
                start = new Date((uint)startTime.Month, (uint)startTime.Year);
78
                end = new Date((uint)endTime.Month, (uint)endTime.Year);
76
                start = null;
77
                end = null;
79 78
            }
80 79

  
81 80
            var weatherFiles = downloader.GetData(pathWeather, start, end);
......
183 182
                    
184 183
                    
185 184
            if (indexLogin < loginList.Count)
186
                res.AddRange(jisList.GetRange(indexLogin, loginList.Count - indexLogin));
185
                res.AddRange(loginList.GetRange(indexLogin, loginList.Count - indexLogin));
187 186

  
188 187
            return res;
189 188
        }
Server/ServerApp/Parser/Parsers/JisParser.cs
15 15
    /// Data parsed from 7am (included) to 18pm (included)
16 16
    /// </summary>
17 17
    /// <author>A. Konig</author>
18
    class JisParser
18
    public class JisParser
19 19
    {
20 20

  
21 21
        /// <summary> Datafile loader  </summary>
......
78 78
        {
79 79
            List<ActivityInfo> jisInfo = new List<ActivityInfo>();
80 80
            
81
            if (!File.Exists(path))
82
                return jisInfo;
83

  
84 81
            List<JisInstance> list =  loader.LoadJisFile(path);
82
            if (list == null)
83
                return jisInfo;
85 84

  
86 85
            // data for each faculty
87 86
            int[] recordedAmount = new int[TagInfo.buildings.Length];
......
107 106
                    for (int k = 0; k < TagInfo.buildings.Length; k++)
108 107
                    {
109 108
                        ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, range);
110
                        jisInfo.Add(dayInfo);
109
                        if (recordedAmount[k] != 0)
110
                            jisInfo.Add(dayInfo);
111 111
                    }
112 112

  
113 113
                    recordedAmount = new int[TagInfo.buildings.Length];
......
141 141
            for (int k = 0; k < TagInfo.buildings.Length; k++)
142 142
            {
143 143
                ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, range);
144
                jisInfo.Add(dayInfo);
144
                if (recordedAmount[k] != 0)
145
                    jisInfo.Add(dayInfo);
145 146
            }
146 147

  
147 148
            return jisInfo;
......
158 159
        private List<ActivityInfo> ProcessOneJisFileAsIntervals(string path, int interval, DateTime startTime, DateTime endTime)
159 160
        {
160 161
            List<ActivityInfo> jisInfo = new List<ActivityInfo>();
161
            
162
            if (!File.Exists(path))
163
                return jisInfo;
164 162

  
165 163
            List<JisInstance> list = loader.LoadJisFile(path);
164
            if (list == null)
165
                return jisInfo;
166 166

  
167 167
            // data for each faculty
168 168
            int[] recordedAmount = new int[TagInfo.buildings.Length];
......
207 207
                    // start time of last interval
208 208
                    DateTime stTime = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, startingTime, 0, 0);
209 209

  
210
                    // TODO zjistit kolik se vynechalo a přidat tolik nul?
211

  
210 212
                    // find end and start time
211 213
                    if (!trigger)
212 214
                        index++;
......
223 225
                    for (int k = 0; k < TagInfo.buildings.Length; k++)
224 226
                    {
225 227
                        ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], stTime, interval);
226
                        jisInfo.Add(dayInfo);
228
                        if (recordedAmount[k] != 0)
229
                            jisInfo.Add(dayInfo);
227 230
                    }
228 231

  
229 232
                    recordedAmount = new int[TagInfo.buildings.Length];
......
254 257
            }
255 258

  
256 259
            // last day
260
            DateTime startT = new DateTime(lastStartTime.Year, lastStartTime.Month, lastStartTime.Day, startingTime, 0, 0);
257 261
            for (int k = 0; k < TagInfo.buildings.Length; k++)
258 262
            {
259
                ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], lastStartTime, interval);
260
                jisInfo.Add(dayInfo);
263
                ActivityInfo dayInfo = new ActivityInfo(TagInfo.buildings[k], recordedAmount[k], startT, interval);
264
                if (recordedAmount[k] != 0)
265
                    jisInfo.Add(dayInfo);
261 266
            }
262 267

  
263 268
            return jisInfo;
Server/ServerApp/Parser/Parsers/LogInParser.cs
77 77
        {
78 78
            List<ActivityInfo> loginInfo = new List<ActivityInfo>();
79 79

  
80
            if (!File.Exists(path))
81
                return loginInfo;
82

  
83 80
            List<LogInInstance> list = loader.LoadLoginFile(path);
81
            if (list == null)
82
                return loginInfo;
84 83

  
85 84
            // data for each faculty
86 85
            int[] recordedAmount = new int[TagInfo.buildings.Length];
......
161 160
        {
162 161
            List<ActivityInfo> loginInfo = new List<ActivityInfo>();
163 162
            
164
            if (!File.Exists(path))
165
                return loginInfo;
166

  
167 163
            List<LogInInstance> list = loader.LoadLoginFile(path);
164
            if (list == null)
165
                return loginInfo;
168 166

  
169 167
            // min/max hour taken into account
170 168
            int[] minmaxHour = new int[] { 7, 18 };
Server/ServerApp/Parser/Parsers/TagInfo.cs
10 10
    /// Class with Tags used in application
11 11
    /// </summary>
12 12
    /// <author>Alex Konig</author>
13
    class TagInfo
13
    public class TagInfo
14 14
    {
15 15
        public static string[] buildings;
16 16

  
Server/ServerApp/Parser/Parsers/WeatherParser.cs
15 15
    /// Data parsed from 7am (included) to 18pm (included)
16 16
    /// </summary>
17 17
    /// <author>A. Konig</author>
18
    class WeatherParser
18
    public class WeatherParser
19 19
    {
20 20

  
21 21
        /// <summary> Datafile loader  </summary>
......
44 44
        {
45 45
            List<WeatherInfo> list = new List<WeatherInfo>();
46 46

  
47
            if (weatherFiles == null || startTime == null || endTime == null || interval <= 0)
47
            if (weatherFiles == null || interval <= 0)
48 48
                return list;
49 49

  
50 50
            // get all files in folder
......
80 80
        {
81 81
            List<WeatherInfo> weatherInfo = new List<WeatherInfo>();
82 82

  
83
            if (!File.Exists(path))
84
                return weatherInfo;
85

  
86 83
            List<WeatherInstance> list = loader.LoadWeatherFile(path);
84
            if (list == null)
85
                return weatherInfo;
87 86

  
88 87
            // array with data [temp, rain, wind, lum]
89 88
            double[] recordedAmount = new double[4];
......
116 115
                }
117 116

  
118 117
                // if not in allowed time window -> discard
119
                if (list[i].dateTime < startTime|| list[i].dateTime > endTime)
118
                if (list[i].dateTime < startTime || list[i].dateTime > endTime)
119
                {
120 120
                    continue;
121
                }
121 122

  
122 123
                // aggregate data
123 124
                recordedAmount[0] += list[i].temp;
......
125 126
                recordedAmount[2] += list[i].wind;
126 127

  
127 128
                if (ValueToConditions.TransferLuxToConditions(list[i].lum * 1000) != WeatherConditions.Dark)
129
                {
128 130
                    recordedAmount[3] += list[i].lum * 1000; weatherValues++;
131
                }
129 132

  
130 133
                values++;
131 134
            }
132 135

  
133 136
            // data from last day
134
            WeatherInfo dayInfo2 = new WeatherInfo(lastStartDay, recordedAmount[0] / values, (int)(recordedAmount[1] / values * 100), recordedAmount[2] / values, recordedAmount[3] / values, range); 
135
            weatherInfo.Add(dayInfo2);
137
            if (values != 0)
138
            {
139
                WeatherInfo dayInfo2 = new WeatherInfo(lastStartDay, recordedAmount[0] / values, (int)(recordedAmount[1] / values * 100), recordedAmount[2] / values, recordedAmount[3] / weatherValues, range);
140
                weatherInfo.Add(dayInfo2);
141
            }
136 142

  
137 143
            return weatherInfo;
138 144
        }
......
149 155
        {
150 156
            List<WeatherInfo> weatherInfo = new List<WeatherInfo>();
151 157

  
152
            if (!File.Exists(path))
153
                return weatherInfo;
154

  
155 158
            List<WeatherInstance> list = loader.LoadWeatherFile(path);
159
            if (list == null)
160
                return weatherInfo;
156 161

  
157 162
            // min/max hour taken into account
158 163
            int[] minmaxHour = new int[] { 7, 18 };
......
169 174
            {
170 175
                to[i] = minmaxHour[0] + interval * (i + 1);
171 176
                data[i] = new double[4];
177
                count[i] = 0;
172 178
            }
173 179

  
174 180
            // first day
......
208 214
                    lastStartTime = date;
209 215
                    count = new int[indices];
210 216
                    for (int l = 0; l < data.Length; l++)
217
                    {
211 218
                        data[l] = new double[4];
219
                        count[l] = 0;
220
                    }
212 221
                }
213 222

  
214 223
                // if not in allowed time window -> discard
Server/ServerApp/Program.cs
33 33
        {
34 34

  
35 35
			// SETUP FOLDERS
36

  
37 36
			Config config = FillConfigInfo(args);
38 37
			if (config == null)
39 38
			{
Server/TestProject/ParserTests/TestingParser.cs
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
}
Server/TestProject/TestProject.csproj
63 63
    </Reference>
64 64
  </ItemGroup>
65 65
  <ItemGroup>
66
    <Compile Include="TestingParser.cs" />
66
    <Compile Include="ParserTests\TestingParser.cs" />
67 67
    <Compile Include="Properties\AssemblyInfo.cs" />
68 68
  </ItemGroup>
69 69
  <ItemGroup>
Server/TestProject/TestingParser.cs
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

  
7
namespace TestProject
8
{
9
    [TestClass]
10
    public class TestingParser
11
    {
12
        [TestMethod]
13
        public void AbstactClassTest()
14
        {
15
            IDataParser p = new DataParser(null);
16
            List<ActivityInfo> aa = p.AttendanceList;
17
            List<WeatherInfo> wa = p.WeatherList;
18

  
19
            DataParser pp = (DataParser)p;
20
            List<ActivityInfo> ap = pp.AttendanceList;
21
            List<WeatherInfo> wp = pp.WeatherList;
22

  
23
            Assert.AreEqual(aa, ap);
24
            Assert.AreEqual(wa, wp);
25
        }
26

  
27
        [TestMethod]
28
        public void MergeListsNull()
29
        {
30
            DataParser target = new DataParser(null);
31
            PrivateObject obj = new PrivateObject(target);
32

  
33
            List<ActivityInfo> jis = null;
34
            List<ActivityInfo> pc = null;
35

  
36
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
37
            Assert.AreEqual(0, retVal.Count);
38
        }
39

  
40
        [TestMethod]
41
        public void MergeListsJisNull()
42
        {
43
            DataParser target = new DataParser(null);
44
            PrivateObject obj = new PrivateObject(target);
45

  
46
            List<ActivityInfo> jis = null;
47
            List<ActivityInfo> pc = new List<ActivityInfo>();
48

  
49
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
50
            Assert.AreEqual(pc, retVal);
51
        }
52

  
53
        [TestMethod]
54
        public void MergeListsPcNull()
55
        {
56
            DataParser target = new DataParser(null);
57
            PrivateObject obj = new PrivateObject(target);
58

  
59
            List<ActivityInfo> jis = new List<ActivityInfo>();
60
            List<ActivityInfo> pc = null;
61

  
62
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("MergeAttendance", jis, pc);
63
            Assert.AreEqual(jis, retVal);
64
        }
65
    }
66
}
TextureEditing/bin/Debug/net5.0/TextureEditing.deps.json
1
{
2
  "runtimeTarget": {
3
    "name": ".NETCoreApp,Version=v5.0",
4
    "signature": ""
5
  },
6
  "compilationOptions": {},
7
  "targets": {
8
    ".NETCoreApp,Version=v5.0": {
9
      "TextureEditing/1.0.0": {
10
        "dependencies": {
11
          "System.Drawing.Common": "5.0.2"
12
        },
13
        "runtime": {
14
          "TextureEditing.dll": {}
15
        }
16
      },
17
      "Microsoft.NETCore.Platforms/5.0.0": {},
18
      "Microsoft.Win32.SystemEvents/5.0.0": {
19
        "dependencies": {
20
          "Microsoft.NETCore.Platforms": "5.0.0"
21
        },
22
        "runtime": {
23
          "lib/netstandard2.0/Microsoft.Win32.SystemEvents.dll": {
24
            "assemblyVersion": "5.0.0.0",
25
            "fileVersion": "5.0.20.51904"
26
          }
27
        },
28
        "runtimeTargets": {
29
          "runtimes/win/lib/netcoreapp3.0/Microsoft.Win32.SystemEvents.dll": {
30
            "rid": "win",
31
            "assetType": "runtime",
32
            "assemblyVersion": "5.0.0.0",
33
            "fileVersion": "5.0.20.51904"
34
          }
35
        }
36
      },
37
      "System.Drawing.Common/5.0.2": {
38
        "dependencies": {
39
          "Microsoft.Win32.SystemEvents": "5.0.0"
40
        },
41
        "runtime": {
42
          "lib/netcoreapp3.0/System.Drawing.Common.dll": {
43
            "assemblyVersion": "5.0.0.2",
44
            "fileVersion": "5.0.421.11614"
45
          }
46
        },
47
        "runtimeTargets": {
48
          "runtimes/unix/lib/netcoreapp3.0/System.Drawing.Common.dll": {
49
            "rid": "unix",
50
            "assetType": "runtime",
51
            "assemblyVersion": "5.0.0.2",
52
            "fileVersion": "5.0.421.11614"
53
          },
54
          "runtimes/win/lib/netcoreapp3.0/System.Drawing.Common.dll": {
55
            "rid": "win",
56
            "assetType": "runtime",
57
            "assemblyVersion": "5.0.0.2",
58
            "fileVersion": "5.0.421.11614"
59
          }
60
        }
61
      }
62
    }
63
  },
64
  "libraries": {
65
    "TextureEditing/1.0.0": {
66
      "type": "project",
67
      "serviceable": false,
68
      "sha512": ""
69
    },
70
    "Microsoft.NETCore.Platforms/5.0.0": {
71
      "type": "package",
72
      "serviceable": true,
73
      "sha512": "sha512-VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ==",
74
      "path": "microsoft.netcore.platforms/5.0.0",
75
      "hashPath": "microsoft.netcore.platforms.5.0.0.nupkg.sha512"
76
    },
77
    "Microsoft.Win32.SystemEvents/5.0.0": {
78
      "type": "package",
79
      "serviceable": true,
80
      "sha512": "sha512-Bh6blKG8VAKvXiLe2L+sEsn62nc1Ij34MrNxepD2OCrS5cpCwQa9MeLyhVQPQ/R4Wlzwuy6wMK8hLb11QPDRsQ==",
81
      "path": "microsoft.win32.systemevents/5.0.0",
82
      "hashPath": "microsoft.win32.systemevents.5.0.0.nupkg.sha512"
83
    },
84
    "System.Drawing.Common/5.0.2": {
85
      "type": "package",
86
      "serviceable": true,
87
      "sha512": "sha512-rvr/M1WPf24ljpvvrVd74+NdjRUJu1bBkspkZcnzSZnmAUQWSvanlQ0k/hVHk+cHufZbZfu7vOh/vYc0q5Uu/A==",
88
      "path": "system.drawing.common/5.0.2",
89
      "hashPath": "system.drawing.common.5.0.2.nupkg.sha512"
90
    }
91
  }
92
}
TextureEditing/bin/Debug/net5.0/TextureEditing.runtimeconfig.dev.json
1
{
2
  "runtimeOptions": {
3
    "additionalProbingPaths": [
4
      "C:\\Users\\Daemon\\.dotnet\\store\\|arch|\\|tfm|",
5
      "C:\\Users\\Daemon\\.nuget\\packages",
6
      "D:\\Instalace\\VS\\Shared\\NuGetPackages"
7
    ]
8
  }
9
}
TextureEditing/bin/Debug/net5.0/TextureEditing.runtimeconfig.json
1
{
2
  "runtimeOptions": {
3
    "tfm": "net5.0",
4
    "framework": {
5
      "name": "Microsoft.NETCore.App",
6
      "version": "5.0.0"
7
    }
8
  }
9
}
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff