Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 3729dcae

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

re #9037 Empty input testing

Zobrazit rozdíly:

Server/ServerApp/Parser/Parsers/JisParser.cs
89 89
            List<ActivityInfo> jisInfo = new List<ActivityInfo>();
90 90
            
91 91
            List<JisInstance> list =  loader.LoadJisFile(path);
92
            if (list == null)
92
            if (list == null || list.Count == 0)
93 93
                return jisInfo;
94 94

  
95 95
            // data for each faculty
......
171 171
            List<ActivityInfo> jisInfo = new List<ActivityInfo>();
172 172

  
173 173
            List<JisInstance> list = loader.LoadJisFile(path);
174
            if (list == null)
174
            if (list == null || list.Count == 0)
175 175
                return jisInfo;
176 176

  
177 177
            // data for each faculty
Server/ServerApp/Parser/Parsers/LogInParser.cs
87 87
            List<ActivityInfo> loginInfo = new List<ActivityInfo>();
88 88

  
89 89
            List<LogInInstance> list = loader.LoadLoginFile(path);
90
            if (list == null)
90
            if (list == null || list.Count == 0)
91 91
                return loginInfo;
92 92

  
93 93
            // data for each faculty
......
173 173
            List<ActivityInfo> loginInfo = new List<ActivityInfo>();
174 174
            
175 175
            List<LogInInstance> list = loader.LoadLoginFile(path);
176
            if (list == null)
176
            if (list == null || list.Count == 0)
177 177
                return loginInfo;
178 178

  
179 179
            // min/max hour taken into account
Server/ServerApp/Parser/Parsers/WeatherParser.cs
90 90
            List<WeatherInfo> weatherInfo = new List<WeatherInfo>();
91 91

  
92 92
            List<WeatherInstance> list = loader.LoadWeatherFile(path);
93
            if (list == null)
93
            if (list == null || list.Count == 0)
94 94
                return weatherInfo;
95 95

  
96 96
            // array with data [temp, rain, wind, lum]
......
165 165
            List<WeatherInfo> weatherInfo = new List<WeatherInfo>();
166 166

  
167 167
            List<WeatherInstance> list = loader.LoadWeatherFile(path);
168
            if (list == null)
169
                return weatherInfo;
168
            if (list == null || list.Count == 0)
169
                    return weatherInfo;
170 170

  
171 171
            // min/max hour taken into account
172 172
            int[] minmaxHour = new int[] { 7, 18 };
Server/ServerAppFunctionalTests/ParserTests/JisParserTesting.cs
162 162

  
163 163
            Assert.AreEqual(0, retVal.Count);
164 164
        }
165

  
166
        [TestMethod]
167
        public void ParseJisDayEmpty()
168
        {
169
            string path = "";
170
            List<WeatherInstance> data = new List<WeatherInstance>();
171

  
172
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
173
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
174

  
175
            JisParser target = new JisParser(dl.Object);
176
            PrivateObject obj = new PrivateObject(target);
177

  
178
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
179

  
180
            Assert.AreEqual(0, retVal.Count);
181
        }
182

  
183

  
184
        [TestMethod]
185
        public void ParseJisDayNull()
186
        {
187
            string path = "";
188
            List<WeatherInstance> data = null;
189

  
190
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
191
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
192

  
193
            JisParser target = new JisParser(dl.Object);
194
            PrivateObject obj = new PrivateObject(target);
195

  
196
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
197

  
198
            Assert.AreEqual(0, retVal.Count);
199
        }
165 200
        #endregion
166 201

  
167 202
        #region Parse hours
203

  
204
        [TestMethod]
205
        public void ParseJisEmpty()
206
        {
207
            string path = "";
208
            List<WeatherInstance> data = new List<WeatherInstance>();
209

  
210
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
211
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
212

  
213
            JisParser target = new JisParser(dl.Object);
214
            PrivateObject obj = new PrivateObject(target);
215

  
216
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
217

  
218
            Assert.AreEqual(0, retVal.Count);
219
        }
220

  
221

  
222
        [TestMethod]
223
        public void ParseJisNull()
224
        {
225
            string path = "";
226
            List<WeatherInstance> data = null;
227

  
228
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
229
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
230

  
231
            JisParser target = new JisParser(dl.Object);
232
            PrivateObject obj = new PrivateObject(target);
233

  
234
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneJisFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
235

  
236
            Assert.AreEqual(0, retVal.Count);
237
        }
238

  
168 239
        [TestMethod]
169 240
        public void ParseJisHourlyOne()
170 241
        {
Server/ServerAppFunctionalTests/ParserTests/LoginParserTesting.cs
175 175

  
176 176
            Assert.AreEqual(0, retVal.Count);
177 177
        }
178

  
179
        [TestMethod]
180
        public void ParseLoginDayEmpty()
181
        {
182
            string path = "";
183
            List<WeatherInstance> data = new List<WeatherInstance>();
184

  
185
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
186
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
187

  
188
            LogInParser target = new LogInParser(dl.Object);
189
            PrivateObject obj = new PrivateObject(target);
190

  
191
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
192

  
193
            Assert.AreEqual(0, retVal.Count);
194
        }
195

  
196

  
197
        [TestMethod]
198
        public void ParseLoginDayNull()
199
        {
200
            string path = "";
201
            List<WeatherInstance> data = null;
202

  
203
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
204
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
205

  
206
            LogInParser target = new LogInParser(dl.Object);
207
            PrivateObject obj = new PrivateObject(target);
208

  
209
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLogInFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
210

  
211
            Assert.AreEqual(0, retVal.Count);
212
        }
178 213
        #endregion
179 214

  
180 215
        #region Parse hours
216
        [TestMethod]
217
        public void ParseLoginEmpty()
218
        {
219
            string path = "";
220
            List<WeatherInstance> data = new List<WeatherInstance>();
221

  
222
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
223
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
224

  
225
            LogInParser target = new LogInParser(dl.Object);
226
            PrivateObject obj = new PrivateObject(target);
227

  
228
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
229

  
230
            Assert.AreEqual(0, retVal.Count);
231
        }
232

  
233

  
234
        [TestMethod]
235
        public void ParseLoginNull()
236
        {
237
            string path = "";
238
            List<WeatherInstance> data = null;
239

  
240
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
241
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
242

  
243
            LogInParser target = new LogInParser(dl.Object);
244
            PrivateObject obj = new PrivateObject(target);
245

  
246
            List<ActivityInfo> retVal = (List<ActivityInfo>)obj.Invoke("ProcessOneLoginFileAsIntervals", path, 2, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
247

  
248
            Assert.AreEqual(0, retVal.Count);
249
        }
250

  
181 251
        [TestMethod]
182 252
        public void ParseLoginHourlyOne()
183 253
        {
Server/ServerAppFunctionalTests/ParserTests/WeatherParserTesting.cs
60 60
            WeatherParser target = new WeatherParser(dl.Object);
61 61
            PrivateObject obj = new PrivateObject(target);
62 62

  
63
            List<ActivityInfo> jis = new List<ActivityInfo>();
64
            List<ActivityInfo> pc = new List<ActivityInfo>();
65

  
66 63
            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));
67 64

  
68 65
            Assert.AreEqual(1, retVal.Count);
......
90 87
            WeatherParser target = new WeatherParser(dl.Object);
91 88
            PrivateObject obj = new PrivateObject(target);
92 89

  
93
            List<ActivityInfo> jis = new List<ActivityInfo>();
94
            List<ActivityInfo> pc = new List<ActivityInfo>();
95

  
96 90
            List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));
97 91

  
98 92
            Assert.AreEqual(2, retVal.Count);
......
121 115
            WeatherParser target = new WeatherParser(dl.Object);
122 116
            PrivateObject obj = new PrivateObject(target);
123 117

  
124
            List<ActivityInfo> jis = new List<ActivityInfo>();
125
            List<ActivityInfo> pc = new List<ActivityInfo>();
126

  
127 118
            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));
128 119

  
129 120
            Assert.AreEqual(1, retVal.Count);
130 121
            Assert.AreEqual(new WeatherInfo(new DateTime(2000, 1, 1, 7, 0, 0), 6, 100, 1, 10_000, 18 - 7), retVal[0]);
131 122
            //Assert.AreEqual(new WeatherInfo(new DateTime(2000, 2, 1, 7, 0, 0), 10, 25, 2, 10_000, 18 - 7), retVal[1]);
132 123
        }
124

  
125
        [TestMethod]
126
        public void ParseWeatherDayEmpty()
127
        {
128
            string path = "";
129
            List<WeatherInstance> data = new List<WeatherInstance>();
130

  
131
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
132
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
133

  
134
            WeatherParser target = new WeatherParser(dl.Object);
135
            PrivateObject obj = new PrivateObject(target);
136

  
137
            List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
138

  
139
            Assert.AreEqual(0, retVal.Count);
140
        }
141

  
142
        [TestMethod]
143
        public void ParseWeatherDayNull()
144
        {
145
            string path = "";
146
            List<WeatherInstance> data = null;
147

  
148
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
149
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
150

  
151
            WeatherParser target = new WeatherParser(dl.Object);
152
            PrivateObject obj = new PrivateObject(target);
153

  
154
            List<WeatherInfo> retVal = (List<WeatherInfo>)obj.Invoke("ProcessOneWeatherFileAsDays", path, new DateTime(2000, 1, 1, 8, 0, 0), new DateTime(2001, 1, 1, 11, 0, 0));
155

  
156
            Assert.AreEqual(0, retVal.Count);
157
        }
133 158
        #endregion
134 159

  
135 160
        #region Parse hours
......
149 174
            WeatherParser target = new WeatherParser(dl.Object);
150 175
            PrivateObject obj = new PrivateObject(target);
151 176

  
152
            List<ActivityInfo> jis = new List<ActivityInfo>();
153
            List<ActivityInfo> pc = new List<ActivityInfo>();
154

  
155 177
            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));
156 178

  
157 179
            Assert.AreEqual(1, retVal.Count);
......
186 208
            WeatherParser target = new WeatherParser(dl.Object);
187 209
            PrivateObject obj = new PrivateObject(target);
188 210

  
189
            List<ActivityInfo> jis = new List<ActivityInfo>();
190
            List<ActivityInfo> pc = new List<ActivityInfo>();
191

  
192 211
            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));
193 212

  
194 213
            Assert.AreEqual(5, retVal.Count);
......
208 227
            Assert.AreEqual(new DateTime(2000, 2, 1, 16, 0, 0), retVal[4].startTime);
209 228
        }
210 229

  
230
        [TestMethod]
231
        public void ParseWeatherEmpty()
232
        {
233
            string path = "";
234
            List<WeatherInstance> data = new List<WeatherInstance>();
235

  
236
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
237
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
238

  
239
            WeatherParser target = new WeatherParser(dl.Object);
240
            PrivateObject obj = new PrivateObject(target);
241

  
242
            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));
243

  
244
            Assert.AreEqual(0, retVal.Count);
245
        }
246

  
247

  
248
        [TestMethod]
249
        public void ParseWeatherNull()
250
        {
251
            string path = "";
252
            List<WeatherInstance> data = null;
253

  
254
            Mock<IDataLoader> dl = new Mock<IDataLoader>();
255
            dl.Setup(m => m.LoadWeatherFile(path)).Returns(data);
256

  
257
            WeatherParser target = new WeatherParser(dl.Object);
258
            PrivateObject obj = new PrivateObject(target);
259

  
260
            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));
261

  
262
            Assert.AreEqual(0, retVal.Count);
263
        }
211 264

  
212 265
        [TestMethod]
213 266
        public void ParseWeatherHourFiltering()
......
237 290
            WeatherParser target = new WeatherParser(dl.Object);
238 291
            PrivateObject obj = new PrivateObject(target);
239 292

  
240
            List<ActivityInfo> jis = new List<ActivityInfo>();
241
            List<ActivityInfo> pc = new List<ActivityInfo>();
242

  
243 293
            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));
244 294

  
245 295
            Assert.AreEqual(3, retVal.Count);

Také k dispozici: Unified diff