11using FontAwesome . Sharp ;
22using System ;
3+ using System . Collections . Generic ;
34using System . ComponentModel ;
45using System . Drawing ;
56using System . Globalization ;
@@ -56,7 +57,7 @@ public void RunTestsAsync(string type, string owner, string name, string procedu
5657
5758 if ( coverage )
5859 {
59- var codeCoverageReportDialog = new CodeCoverageReportDialog ( GetPath ( convertToType ( type ) , owner , name , procedure ) ) ;
60+ var codeCoverageReportDialog = new CodeCoverageReportDialog ( GetPath ( type , owner , name , procedure ) ) ;
6061 var dialogResult = codeCoverageReportDialog . ShowDialog ( ) ;
6162 if ( dialogResult == DialogResult . OK )
6263 {
@@ -90,19 +91,19 @@ public void RunTestsAsync(string type, string owner, string name, string procedu
9091
9192 private void RunTests ( string type , string owner , string name , string procedure )
9293 {
93- Task . Factory . StartNew ( ( ) => testRunner . RunTests ( convertToType ( type ) , owner , name , procedure ) ) ;
94+ Task . Factory . StartNew ( ( ) => testRunner . RunTests ( GetPath ( type , owner , name , procedure ) ) ) ;
9495 Running = true ;
9596 }
9697
9798
9899
99100 private void RunWithCoverage ( string type , string owner , string name , string procedure , CodeCoverageReportDialog codeCoverageReportDialog )
100101 {
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 ( ) ) ;
104105
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 ) ) ;
106107 Running = true ;
107108 }
108109
@@ -208,7 +209,7 @@ private void CollectReport()
208209 } ) ;
209210 }
210211
211- private string ConvertToVarcharList ( string listValue )
212+ private List < string > ConvertToList ( string listValue )
212213 {
213214 if ( string . IsNullOrWhiteSpace ( listValue ) )
214215 {
@@ -219,51 +220,29 @@ private string ConvertToVarcharList(string listValue)
219220 if ( listValue . Contains ( " " ) )
220221 {
221222 var parts = listValue . Split ( ' ' ) ;
222- return JoinParts ( parts ) ;
223+ return new List < string > ( parts ) ;
223224 }
224225 else if ( listValue . Contains ( "," ) )
225226 {
226227 var parts = listValue . Split ( ',' ) ;
227- return JoinParts ( parts ) ;
228+ return new List < string > ( parts ) ;
228229 }
229230 else if ( listValue . Contains ( "\n " ) )
230231 {
231232 var parts = listValue . Split ( '\n ' ) ;
232- return JoinParts ( parts ) ;
233+ return new List < string > ( parts ) ;
233234 }
234235 else
235236 {
236- return $ "' { listValue } '" ;
237+ return new List < string > ( ) { listValue } ;
237238 }
238239 }
239240 }
240241
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-
263242 /*
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+ */
267246 private void UpdateProgressBar ( int completedTests )
268247 {
269248 int newValue = completedTests * Steps + 1 ;
@@ -284,25 +263,23 @@ private void SetWindowTitle(string type, string owner, string name, string proce
284263 {
285264 var startTime = DateTime . Now . ToString ( CultureInfo . CurrentCulture ) ;
286265 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 ] ;
289268 this . Text = $ "{ path } { startTime } ";
290269 }
291270
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 )
293272 {
294273 switch ( type )
295274 {
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 } " } ;
304281 default :
305- return "" ;
282+ return new List < string > ( ) { owner } ;
306283 }
307284 }
308285
@@ -453,20 +430,7 @@ private void CreateTestResults(test test)
453430 } ) ;
454431 }
455432 }
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+
470434 private void btnClose_Click ( object sender , System . EventArgs e )
471435 {
472436 Close ( ) ;
0 commit comments