@@ -9,6 +9,7 @@ namespace Reqnroll.VisualStudio.ReqnrollConnector.Tests;
99public class SampleValidationTests
1010{
1111 private const string ConnectorConfiguration = "Debug" ;
12+ private const string TargetFrameworkToBeUsedForNet4Projects = "net10.0" ;
1213 protected readonly ITestOutputHelper TestOutputHelper ;
1314
1415 public SampleValidationTests ( ITestOutputHelper testOutputHelper )
@@ -30,6 +31,14 @@ public void ExploratoryTestProjects(string testCase, string projectFile, string
3031 ValidateProject ( testCase , projectFile , repositoryDirectory ) ;
3132 }
3233
34+ // example of running tests for a local repository (the path is relative to the solution root or absolute)
35+ //[Theory]
36+ //[MemberData(nameof(GetProjectsForRepository), @"..\Reqnroll.ExploratoryTestProjects\VsExtConnectorTestSamples", "")]
37+ //public void LocalExploratoryTestProjects(string testCase, string projectFile, string repositoryDirectory)
38+ //{
39+ // ValidateProject(testCase, projectFile, repositoryDirectory);
40+ //}
41+
3342 protected void ValidateProject ( string testCase , string projectFile , string repositoryDirectory )
3443 {
3544 TestOutputHelper . WriteLine ( "Running Test Case: " + testCase ) ;
@@ -137,15 +146,24 @@ public static TheoryData<string, string, string> GetProjectsForRepository(string
137146
138147 internal static string PrepareRepository ( string repositoryUrl )
139148 {
149+ if ( ! repositoryUrl . StartsWith ( "https://" ) )
150+ {
151+ // assume folder (absolute or relative to the solution root)
152+ var localRepositoryDirectory =
153+ Path . GetFullPath ( Path . Combine ( GetSolutionRoot ( ) , repositoryUrl ) ) ;
154+ Directory . Exists ( localRepositoryDirectory ) . Should ( ) . BeTrue ( $ "Repository folder not found: { localRepositoryDirectory } ") ;
155+ return localRepositoryDirectory ;
156+ }
157+
140158 var repositoryName = GetRepositoryNameFromUrl ( repositoryUrl ) ;
141- var rootDirectory = Path . Combine ( Path . GetTempPath ( ) , "ReqnrollSamples" ) ;
142- Directory . CreateDirectory ( rootDirectory ) ;
159+ var tempRootDirectory = Path . Combine ( Path . GetTempPath ( ) , "ReqnrollSamples" ) ;
160+ Directory . CreateDirectory ( tempRootDirectory ) ;
143161
144- var repositoryDirectory = Path . Combine ( rootDirectory , repositoryName ) ;
162+ var repositoryDirectory = Path . Combine ( tempRootDirectory , repositoryName ) ;
145163
146164 if ( ! Directory . Exists ( repositoryDirectory ) )
147165 {
148- RunProcessStatic ( rootDirectory , "git" , $ "clone { repositoryUrl } \" { repositoryDirectory } \" ") ;
166+ RunProcessStatic ( tempRootDirectory , "git" , $ "clone { repositoryUrl } \" { repositoryDirectory } \" ") ;
149167 }
150168 else
151169 {
@@ -165,6 +183,11 @@ internal static string PrepareRepository(string repositoryUrl)
165183
166184 internal static string GetRepositoryNameFromUrl ( string repositoryUrl )
167185 {
186+ if ( ! repositoryUrl . StartsWith ( "https://" ) )
187+ {
188+ return repositoryUrl . Split ( Path . DirectorySeparatorChar , Path . AltDirectorySeparatorChar ) . Last ( ) ;
189+ }
190+
168191 var uri = new Uri ( repositoryUrl ) ;
169192 var lastSegment = uri . Segments . Last ( ) . Trim ( '/' ) ;
170193 if ( lastSegment . EndsWith ( ".git" , StringComparison . OrdinalIgnoreCase ) )
@@ -176,13 +199,18 @@ internal static string GetRepositoryNameFromUrl(string repositoryUrl)
176199 private static string GetConnectorPath ( string targetFramework )
177200 {
178201 if ( targetFramework . StartsWith ( "net4" ) )
179- targetFramework = "net10.0" ;
202+ targetFramework = TargetFrameworkToBeUsedForNet4Projects ;
203+
204+ var connectorDir = Path . Combine ( GetSolutionRoot ( ) , "Connectors" , "bin" , ConnectorConfiguration , $ "Reqnroll-Generic-{ targetFramework } ") ;
205+ return Path . Combine ( connectorDir , "reqnroll-vs.dll" ) ;
206+ }
180207
208+ private static string GetSolutionRoot ( )
209+ {
181210 var assemblyLocation = Assembly . GetExecutingAssembly ( ) . Location ;
182211 var testAssemblyDir = Path . GetDirectoryName ( assemblyLocation ) ! ;
183212 var solutionRoot = Path . GetFullPath ( Path . Combine ( testAssemblyDir , ".." , ".." , ".." , ".." , ".." , ".." ) ) ;
184- var connectorDir = Path . Combine ( solutionRoot , "Connectors" , "bin" , ConnectorConfiguration , $ "Reqnroll-Generic-{ targetFramework } ") ;
185- return Path . Combine ( connectorDir , "reqnroll-vs.dll" ) ;
213+ return solutionRoot ;
186214 }
187215
188216 private static DiscoveryResult ExtractDiscoveryResult ( string stdOutput )
0 commit comments