|
1 | 1 | using FontAwesome.Sharp; |
2 | 2 | using System; |
| 3 | +using System.Collections.Generic; |
3 | 4 | using System.ComponentModel; |
4 | 5 | using System.Drawing; |
5 | 6 | using System.Globalization; |
@@ -56,7 +57,7 @@ public void RunTestsAsync(string type, string owner, string name, string procedu |
56 | 57 |
|
57 | 58 | if (coverage) |
58 | 59 | { |
59 | | - var codeCoverageReportDialog = new CodeCoverageReportDialog(GetPath(convertToType(type), owner, name, procedure)); |
| 60 | + var codeCoverageReportDialog = new CodeCoverageReportDialog(GetPath(type, owner, name, procedure)); |
60 | 61 | var dialogResult = codeCoverageReportDialog.ShowDialog(); |
61 | 62 | if (dialogResult == DialogResult.OK) |
62 | 63 | { |
@@ -90,19 +91,19 @@ public void RunTestsAsync(string type, string owner, string name, string procedu |
90 | 91 |
|
91 | 92 | private void RunTests(string type, string owner, string name, string procedure) |
92 | 93 | { |
93 | | - Task.Factory.StartNew(() => testRunner.RunTests(convertToType(type), owner, name, procedure)); |
| 94 | + Task.Factory.StartNew(() => testRunner.RunTests(GetPath(type, owner, name, procedure))); |
94 | 95 | Running = true; |
95 | 96 | } |
96 | 97 |
|
97 | 98 |
|
98 | 99 |
|
99 | 100 | private void RunWithCoverage(string type, string owner, string name, string procedure, CodeCoverageReportDialog codeCoverageReportDialog) |
100 | 101 | { |
101 | | - var schemas = ConvertToVarcharList(codeCoverageReportDialog.GetSchemas()); |
102 | | - var includes = ConvertToVarcharList(codeCoverageReportDialog.GetIncludes()); |
103 | | - var excludes = ConvertToVarcharList(codeCoverageReportDialog.GetExcludes()); |
| 102 | + var schemas = ConvertToList(codeCoverageReportDialog.GetSchemas()); |
| 103 | + var includes = ConvertToList(codeCoverageReportDialog.GetIncludes()); |
| 104 | + var excludes = ConvertToList(codeCoverageReportDialog.GetExcludes()); |
104 | 105 |
|
105 | | - Task.Factory.StartNew(() => testRunner.RunTestsWithCoverage(convertToType(type), owner, name, procedure, schemas, includes, excludes)); |
| 106 | + Task.Factory.StartNew(() => testRunner.RunTestsWithCoverage(GetPath(type, owner, name, procedure), schemas, includes, excludes)); |
106 | 107 | Running = true; |
107 | 108 | } |
108 | 109 |
|
@@ -208,7 +209,7 @@ private void CollectReport() |
208 | 209 | }); |
209 | 210 | } |
210 | 211 |
|
211 | | - private string ConvertToVarcharList(string listValue) |
| 212 | + private List<string> ConvertToList(string listValue) |
212 | 213 | { |
213 | 214 | if (string.IsNullOrWhiteSpace(listValue)) |
214 | 215 | { |
@@ -219,51 +220,29 @@ private string ConvertToVarcharList(string listValue) |
219 | 220 | if (listValue.Contains(" ")) |
220 | 221 | { |
221 | 222 | var parts = listValue.Split(' '); |
222 | | - return JoinParts(parts); |
| 223 | + return new List<string>(parts); |
223 | 224 | } |
224 | 225 | else if (listValue.Contains(",")) |
225 | 226 | { |
226 | 227 | var parts = listValue.Split(','); |
227 | | - return JoinParts(parts); |
| 228 | + return new List<string>(parts); |
228 | 229 | } |
229 | 230 | else if (listValue.Contains("\n")) |
230 | 231 | { |
231 | 232 | var parts = listValue.Split('\n'); |
232 | | - return JoinParts(parts); |
| 233 | + return new List<string>(parts); |
233 | 234 | } |
234 | 235 | else |
235 | 236 | { |
236 | | - return $"'{listValue}'"; |
| 237 | + return new List<string>() { listValue }; |
237 | 238 | } |
238 | 239 | } |
239 | 240 | } |
240 | 241 |
|
241 | | - private static string JoinParts(string[] parts) |
242 | | - { |
243 | | - var sb = new StringBuilder(); |
244 | | - var first = true; |
245 | | - foreach (var part in parts) |
246 | | - { |
247 | | - if (!string.IsNullOrEmpty(part)) |
248 | | - { |
249 | | - if (!first) |
250 | | - { |
251 | | - sb.Append(","); |
252 | | - } |
253 | | - |
254 | | - sb.Append("'").Append(part).Append("'"); |
255 | | - |
256 | | - first = false; |
257 | | - } |
258 | | - } |
259 | | - |
260 | | - return sb.ToString(); |
261 | | - } |
262 | | - |
263 | 242 | /* |
264 | | - * Workaround for the progressbar animation that produces lagging |
265 | | - * https://stackoverflow.com/questions/5332616/disabling-net-progressbar-animation-when-changing-value |
266 | | - */ |
| 243 | + * Workaround for the progressbar animation that produces lagging |
| 244 | + * https://stackoverflow.com/questions/5332616/disabling-net-progressbar-animation-when-changing-value |
| 245 | + */ |
267 | 246 | private void UpdateProgressBar(int completedTests) |
268 | 247 | { |
269 | 248 | int newValue = completedTests * Steps + 1; |
@@ -284,25 +263,23 @@ private void SetWindowTitle(string type, string owner, string name, string proce |
284 | 263 | { |
285 | 264 | var startTime = DateTime.Now.ToString(CultureInfo.CurrentCulture); |
286 | 265 | txtStart.Text = startTime; |
287 | | - var path = GetPath(convertToType(type), owner, name, procedure); |
288 | | - txtPath.Text = path; |
| 266 | + var path = GetPath(type, owner, name, procedure); |
| 267 | + txtPath.Text = path[0]; |
289 | 268 | this.Text = $"{path} {startTime}"; |
290 | 269 | } |
291 | 270 |
|
292 | | - private string GetPath(Type type, string owner, string name, string procedure) |
| 271 | + private List<string> GetPath(string type, string owner, string name, string procedure) |
293 | 272 | { |
294 | 273 | switch (type) |
295 | 274 | { |
296 | | - case Type.User: |
297 | | - return name; |
298 | | - case Type.Package: |
299 | | - return $"{owner}.{name}"; |
300 | | - case Type.Procedure: |
301 | | - return $"{owner}.{name}.{procedure}"; |
302 | | - case Type.All: |
303 | | - return owner; |
| 275 | + case "USER": |
| 276 | + return new List<string>() { name }; |
| 277 | + case "PACKAGE": |
| 278 | + return new List<string>() { $"{owner}.{name}" }; |
| 279 | + case "PROCEDURE": |
| 280 | + return new List<string>() { $"{owner}.{name}.{procedure}" }; |
304 | 281 | default: |
305 | | - return ""; |
| 282 | + return new List<string>() { owner }; |
306 | 283 | } |
307 | 284 | } |
308 | 285 |
|
@@ -453,20 +430,7 @@ private void CreateTestResults(test test) |
453 | 430 | }); |
454 | 431 | } |
455 | 432 | } |
456 | | - private Type convertToType(string type) |
457 | | - { |
458 | | - switch (type) |
459 | | - { |
460 | | - case "USER": |
461 | | - return Type.User; |
462 | | - case "PACKAGE": |
463 | | - return Type.Package; |
464 | | - case "PROCEDURE": |
465 | | - return Type.Procedure; |
466 | | - default: |
467 | | - return Type.All; |
468 | | - } |
469 | | - } |
| 433 | + |
470 | 434 | private void btnClose_Click(object sender, System.EventArgs e) |
471 | 435 | { |
472 | 436 | Close(); |
|