@@ -18,14 +18,29 @@ Describe 'Find-Member cmdlet tests' {
1818 }
1919
2020 It ' filters passed members' {
21- $source = [type ] | Find-Member
21+ $source = [powershell ] | Find-Member - Force
2222 $results = $source | Find-Member - Static
2323
2424 $results | ShouldAll { $_ -in $source }
2525 $results.Count | Should -Not - Be $source.Count
2626 }
2727 }
2828
29+ It ' gets all members with no input' {
30+ $results = Find-Member
31+ $results.Count | Should - BeGreaterThan 10000
32+ }
33+
34+ It ' matches nonpublic members with Force' {
35+ $result = $ExecutionContext.SessionState | Find-Member - Force
36+
37+ # A nonpublic member is present
38+ $result | ShouldAny { $_.Name -eq ' Internal' -and ' Property' -eq $_.MemberType }
39+
40+ # A public member is still present
41+ $result | ShouldAny { $_.Name -eq ' Module' -and ' Property' -eq $_.MemberType }
42+ }
43+
2944 It ' matches with FilterScript' {
3045 $result = [powershell ] |
3146 Find-Member - FilterScript { $_.Name -eq ' Create' -and $_.GetParameters ().Count -eq 0 }
@@ -58,6 +73,31 @@ Describe 'Find-Member cmdlet tests' {
5873 ShouldAny { $_.Name -eq ' Create' }
5974 }
6075
76+ It ' return type matches constructors' {
77+ [System.Collections.Generic.List [string ]] |
78+ Find-Member - ReturnType System.Collections.Generic.List[string ] |
79+ ShouldAny { ' Constructor' -eq $_.MemberType }
80+ }
81+
82+ It ' unwraps target types with elements' {
83+ $result = [System.Management.Automation.Language.Parser ] |
84+ Find-Member - ParameterType System.Management.Automation.Language.Token
85+
86+ $result | ShouldAny {
87+ ($parameters = $_.GetParameters ()) -and
88+ $parameters [1 ].ParameterType.IsByRef -and
89+ $parameters [1 ].ParameterType.GetElementType().IsArray
90+ }
91+ }
92+
93+ It ' return type matches fields' {
94+ $contextType = Find-Type ExecutionContext - Namespace * Automation - Force
95+ $result = $ExecutionContext | Find-Member - ReturnType $contextType - Force
96+
97+ $result.MemberType | Should - Be Field
98+ $result.FieldType | Should - Be $contextType
99+ }
100+
61101 It ' filters to virtual members' {
62102 $results = [runspace ] | Find-Member - Virtual
63103
@@ -89,4 +129,15 @@ Describe 'Find-Member cmdlet tests' {
89129 $results | ShouldAll { $_.Name -ne ' AddScript' }
90130 $results | ShouldAny { $_.Name -eq ' Create' }
91131 }
132+
133+ It ' gets members for passed objects only once per type' {
134+ $powershells = [powershell ]::Create(), [powershell ]::Create()
135+ try {
136+ $result = $powershells | Find-Member
137+ } finally {
138+ $powershells.ForEach (' Dispose' )
139+ }
140+
141+ $result.Where { $_.Name -eq ' Create' }.Count | Should - Be 3
142+ }
92143}
0 commit comments