@@ -18,6 +18,7 @@ public class WorkspaceTests
18
18
private static readonly Version PowerShellVersion = new Version ( "5.0" ) ;
19
19
20
20
[ Fact ]
21
+ [ Trait ( "Category" , "Workspace" ) ]
21
22
public void CanResolveWorkspaceRelativePath ( )
22
23
{
23
24
string workspacePath = TestUtilities . NormalizePath ( "c:/Test/Workspace/" ) ;
@@ -41,6 +42,42 @@ public void CanResolveWorkspaceRelativePath()
41
42
}
42
43
43
44
[ Fact ]
45
+ [ Trait ( "Category" , "Workspace" ) ]
46
+ public void CanRecurseDirectoryTree ( )
47
+ {
48
+ Workspace workspace = new Workspace ( PowerShellVersion , Logging . NullLogger ) ;
49
+ workspace . WorkspacePath = TestUtilities . NormalizePath ( "Fixtures/Workspace" ) ;
50
+
51
+ IEnumerable < string > result = workspace . EnumeratePSFiles ( ) ;
52
+ List < string > fileList = new List < string > ( ) ;
53
+ foreach ( string file in result ) { fileList . Add ( file ) ; }
54
+ // Assume order is not important from EnumeratePSFiles and sort the array so we can use deterministic asserts
55
+ fileList . Sort ( ) ;
56
+
57
+ if ( RuntimeInformation . FrameworkDescription . StartsWith ( ".NET Core" ) )
58
+ {
59
+ // .Net Core doesn't appear to use the same three letter pattern matching rule although the docs
60
+ // suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1'
61
+ // ref https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?view=netcore-2.1#System_IO_Directory_GetFiles_System_String_System_String_System_IO_EnumerationOptions_
62
+ Assert . Equal ( 4 , fileList . Count ) ;
63
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
64
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
65
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
66
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 3 ] ) ;
67
+ }
68
+ else
69
+ {
70
+ Assert . Equal ( 5 , fileList . Count ) ;
71
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
72
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
73
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
74
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "other" , "other.ps1xml" ) , fileList [ 3 ] ) ;
75
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 4 ] ) ;
76
+ }
77
+ }
78
+
79
+ [ Fact ]
80
+ [ Trait ( "Category" , "Workspace" ) ]
44
81
public void CanDetermineIsPathInMemory ( )
45
82
{
46
83
string tempDir = Path . GetTempPath ( ) ;
@@ -78,6 +115,7 @@ public void CanDetermineIsPathInMemory()
78
115
}
79
116
80
117
[ Theory ( ) ]
118
+ [ Trait ( "Category" , "Workspace" ) ]
81
119
[ MemberData ( nameof ( PathsToResolve ) , parameters : 2 ) ]
82
120
public void CorrectlyResolvesPaths ( string givenPath , string expectedPath )
83
121
{
0 commit comments