1- using System ;
21using System . IO ;
3- using System . Linq ;
4- using NUnit . Framework ;
52using pyRevitExtensionParser ;
63using static pyRevitExtensionParser . ExtensionParser ;
74
@@ -14,18 +11,15 @@ public class CSharpScriptTests
1411 public void TestCSharpScriptDetection ( )
1512 {
1613 // Test that the parser can detect C# scripts in pyRevitDevTools extension
17- var extensionRoot = Path . GetFullPath ( Path . Combine (
18- TestContext . CurrentContext . TestDirectory ,
19- ".." , ".." , ".." , ".." , ".." , ".." ,
20- "extensions" ) ) ;
14+ var extensionPath = TestConfiguration . TestExtensionPath ;
2115
22- if ( ! Directory . Exists ( extensionRoot ) )
16+ if ( ! Directory . Exists ( extensionPath ) )
2317 {
24- Assert . Inconclusive ( "Extensions directory not found at: " + extensionRoot ) ;
18+ Assert . Inconclusive ( "pyRevitDevTools extension directory not found at: " + extensionPath ) ;
2519 return ;
2620 }
2721
28- var extensions = ParseInstalledExtensions ( new [ ] { extensionRoot } ) ;
22+ var extensions = ParseInstalledExtensions ( new [ ] { extensionPath } ) ;
2923
3024 // Find the pyRevitDevTools extension
3125 var devToolsExtension = extensions . FirstOrDefault ( e => e . Name == "pyRevitDevTools" ) ;
@@ -60,7 +54,8 @@ public void TestCSharpScriptDetection()
6054 public void TestSpecificCSharpScript ( )
6155 {
6256 // Test the specific C# script mentioned in the user's request
63- var scriptPath = @"C:\dev\romangolev\pyRevit\extensions\pyRevitDevTools.extension\pyRevitDev.tab\Debug.panel\Bundle Tests.pulldown\Test C# Script.pushbutton" ;
57+ var extensionPath = TestConfiguration . TestExtensionPath ;
58+ var scriptPath = Path . Combine ( extensionPath , "pyRevitDev.tab" , "Debug.panel" , "Bundle Tests.pulldown" , "Test C# Script.pushbutton" ) ;
6459
6560 if ( ! Directory . Exists ( scriptPath ) )
6661 {
@@ -72,8 +67,7 @@ public void TestSpecificCSharpScript()
7267 Assert . IsTrue ( File . Exists ( scriptFile ) , "script.cs should exist in the Test C# Script button" ) ;
7368
7469 // Parse the extension containing this script
75- var extensionRoot = Path . GetFullPath ( Path . Combine ( scriptPath , ".." , ".." , ".." , ".." ) ) ;
76- var extensions = ParseInstalledExtensions ( new [ ] { extensionRoot } ) ;
70+ var extensions = ParseInstalledExtensions ( new [ ] { extensionPath } ) ;
7771
7872 var devToolsExtension = extensions . FirstOrDefault ( e => e . Name == "pyRevitDevTools" ) ;
7973 Assert . IsNotNull ( devToolsExtension , "pyRevitDevTools extension should be parsed" ) ;
@@ -103,18 +97,15 @@ public void TestSpecificCSharpScript()
10397 public void TestMultipleScriptTypes ( )
10498 {
10599 // Test that the parser can handle various script types
106- var extensionRoot = Path . GetFullPath ( Path . Combine (
107- TestContext . CurrentContext . TestDirectory ,
108- ".." , ".." , ".." , ".." , ".." , ".." ,
109- "extensions" ) ) ;
100+ var extensionPath = TestConfiguration . TestExtensionPath ;
110101
111- if ( ! Directory . Exists ( extensionRoot ) )
102+ if ( ! Directory . Exists ( extensionPath ) )
112103 {
113- Assert . Inconclusive ( "Extensions directory not found" ) ;
104+ Assert . Inconclusive ( "pyRevitDevTools extension directory not found at: " + extensionPath ) ;
114105 return ;
115106 }
116107
117- var extensions = ParseInstalledExtensions ( new [ ] { extensionRoot } ) ;
108+ var extensions = ParseInstalledExtensions ( new [ ] { extensionPath } ) ;
118109
119110 var allScripts = new System . Collections . Generic . List < ParsedComponent > ( ) ;
120111 foreach ( var ext in extensions )
@@ -242,18 +233,15 @@ private System.Collections.Generic.List<ParsedComponent> FindAllScripts(ParsedCo
242233 public void TestCSharpScriptModuleLoading ( )
243234 {
244235 // Test that modules are parsed and can be found
245- var extensionRoot = Path . GetFullPath ( Path . Combine (
246- TestContext . CurrentContext . TestDirectory ,
247- ".." , ".." , ".." , ".." , ".." , ".." ,
248- "extensions" ) ) ;
236+ var extensionPath = TestConfiguration . TestExtensionPath ;
249237
250- if ( ! Directory . Exists ( extensionRoot ) )
238+ if ( ! Directory . Exists ( extensionPath ) )
251239 {
252- Assert . Inconclusive ( "Extensions directory not found at: " + extensionRoot ) ;
240+ Assert . Inconclusive ( "pyRevitDevTools extension directory not found at: " + extensionPath ) ;
253241 return ;
254242 }
255243
256- var extensions = ParseInstalledExtensions ( new [ ] { extensionRoot } ) ;
244+ var extensions = ParseInstalledExtensions ( new [ ] { extensionPath } ) ;
257245 var devToolsExtension = extensions . FirstOrDefault ( e => e . Name == "pyRevitDevTools" ) ;
258246
259247 if ( devToolsExtension == null )
@@ -263,7 +251,7 @@ public void TestCSharpScriptModuleLoading()
263251 }
264252
265253 // Find the Test C# Script component
266- var scriptPath = @"C:\dev\romangolev\pyRevit\extensions\pyRevitDevTools.extension\ pyRevitDev.tab\ Debug.panel\ Bundle Tests.pulldown\ Test C# Script.pushbutton";
254+ var scriptPath = Path . Combine ( extensionPath , " pyRevitDev.tab" , " Debug.panel" , " Bundle Tests.pulldown" , " Test C# Script.pushbutton") ;
267255 var testCSharpScript = FindComponentByPath ( devToolsExtension , scriptPath ) ;
268256
269257 if ( testCSharpScript == null )
@@ -303,10 +291,7 @@ public void TestCSharpScriptModuleLoading()
303291 public void TestLinkButtonDetection ( )
304292 {
305293 // Test that the parser can detect LinkButton bundles
306- var devToolsPath = Path . GetFullPath ( Path . Combine (
307- TestContext . CurrentContext . TestDirectory ,
308- ".." , ".." , ".." , ".." , ".." , ".." ,
309- "extensions" , "pyRevitDevTools.extension" ) ) ;
294+ var devToolsPath = TestConfiguration . TestExtensionPath ;
310295
311296 TestContext . Out . WriteLine ( $ "Looking for pyRevitDevTools at: { devToolsPath } ") ;
312297
0 commit comments