@@ -24,6 +24,7 @@ public class WorkspaceTests
24
24
: string . Empty ;
25
25
26
26
[ Fact ]
27
+ [ Trait ( "Category" , "Workspace" ) ]
27
28
public void CanResolveWorkspaceRelativePath ( )
28
29
{
29
30
string workspacePath = TestUtilities . NormalizePath ( "c:/Test/Workspace/" ) ;
@@ -47,6 +48,42 @@ public void CanResolveWorkspaceRelativePath()
47
48
}
48
49
49
50
[ Fact ]
51
+ [ Trait ( "Category" , "Workspace" ) ]
52
+ public void CanRecurseDirectoryTree ( )
53
+ {
54
+ Workspace workspace = new Workspace ( PowerShellVersion , Logging . NullLogger ) ;
55
+ workspace . WorkspacePath = TestUtilities . NormalizePath ( "Fixtures/Workspace" ) ;
56
+
57
+ IEnumerable < string > result = workspace . EnumeratePSFiles ( ) ;
58
+ List < string > fileList = new List < string > ( ) ;
59
+ foreach ( string file in result ) { fileList . Add ( file ) ; }
60
+ // Assume order is not important from EnumeratePSFiles and sort the array so we can use deterministic asserts
61
+ fileList . Sort ( ) ;
62
+
63
+ if ( RuntimeInformation . FrameworkDescription . StartsWith ( ".NET Core" ) )
64
+ {
65
+ // .Net Core doesn't appear to use the same three letter pattern matching rule although the docs
66
+ // suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1'
67
+ // 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_
68
+ Assert . Equal ( 4 , fileList . Count ) ;
69
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
70
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
71
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
72
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 3 ] ) ;
73
+ }
74
+ else
75
+ {
76
+ Assert . Equal ( 5 , fileList . Count ) ;
77
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
78
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
79
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
80
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "other" , "other.ps1xml" ) , fileList [ 3 ] ) ;
81
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 4 ] ) ;
82
+ }
83
+ }
84
+
85
+ [ Fact ]
86
+ [ Trait ( "Category" , "Workspace" ) ]
50
87
public void CanDetermineIsPathInMemory ( )
51
88
{
52
89
string tempDir = Path . GetTempPath ( ) ;
@@ -84,6 +121,7 @@ public void CanDetermineIsPathInMemory()
84
121
}
85
122
86
123
[ Theory ( ) ]
124
+ [ Trait ( "Category" , "Workspace" ) ]
87
125
[ MemberData ( nameof ( PathsToResolve ) , parameters : 2 ) ]
88
126
public void CorrectlyResolvesPaths ( string givenPath , string expectedPath )
89
127
{
0 commit comments