@@ -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,43 @@ 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
+ // TODO: Is order important? or just collected in depth-first order?
55
+ // TODO: For now assume order is not important and sort the array so we can use deterministic asserts
56
+ fileList . Sort ( ) ;
57
+
58
+ if ( RuntimeInformation . FrameworkDescription . StartsWith ( ".NET Core" ) )
59
+ {
60
+ // .Net Core doesn't appear to use the same three letter pattern matching rule although the docs
61
+ // suggest it should be find the '.ps1xml' files because we search for the pattern '*.ps1'
62
+ // 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_
63
+ Assert . Equal ( 4 , fileList . Count ) ;
64
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
65
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
66
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
67
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 3 ] ) ;
68
+ }
69
+ else
70
+ {
71
+ Assert . Equal ( 5 , fileList . Count ) ;
72
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "donotfind.ps1" ) , fileList [ 0 ] ) ;
73
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psd1" ) , fileList [ 1 ] ) ;
74
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "nested" , "nestedmodule.psm1" ) , fileList [ 2 ] ) ;
75
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "other" , "other.ps1xml" ) , fileList [ 3 ] ) ;
76
+ Assert . Equal ( Path . Combine ( workspace . WorkspacePath , "rootfile.ps1" ) , fileList [ 4 ] ) ;
77
+ }
78
+ }
79
+
80
+ [ Fact ]
81
+ [ Trait ( "Category" , "Workspace" ) ]
44
82
public void CanDetermineIsPathInMemory ( )
45
83
{
46
84
string tempDir = Path . GetTempPath ( ) ;
@@ -78,6 +116,7 @@ public void CanDetermineIsPathInMemory()
78
116
}
79
117
80
118
[ Theory ( ) ]
119
+ [ Trait ( "Category" , "Workspace" ) ]
81
120
[ MemberData ( nameof ( PathsToResolve ) , parameters : 2 ) ]
82
121
public void CorrectlyResolvesPaths ( string givenPath , string expectedPath )
83
122
{
0 commit comments