Skip to content

Commit

Permalink
KOAN: Add koan for properties and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
vexx32 committed Dec 28, 2018
1 parent 267c7d3 commit 66e8703
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions PSKoans/Koans/Constructs/AboutPSObjects.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,41 @@ param()

Describe 'PSObject' {
BeforeAll {
$Object = 'Stand for nothing; fall for everything.'
$Object = @('Stand for nothing; fall for everything.')
}

It 'is accessed via a hidden .PSObject property' {
<#
The .PSObject member contains many properties, but the .PSObject property itself does not
actually tab-complete, though its child properties do.
#>
$PSObjectProperties = ($Object.PSObject | Get-Member).Name
$PSObjectProperties = ($Object.PSObject | Get-Member -MemberType Properties).Name

@(
'BaseObject'
'__'
'Members'
'Methods'
'__'
'__'
) | Should -Be $PSObjectProperties
}

It 'details the base object properties and methods' {
$PropertyNames = @(
__
'Copy'
'Equals'
__
'GetMetaObject'
__
__
'ToString'
__
'ImmediateBaseObject'
'LongLength'
__
'Methods'
'SyncRoot'
__
'IsFixedSize'
__
) | Should -Be $PSObjectProperties
'Count'
)
$PropertyNames | Should -Be $Object.PSObject.Properties.Name

$Methods = $Object.PSObject.Methods
__ | Should -Be $Methods.Count
$Methods['__'].Name | Should -Be 'Length'
}
}

0 comments on commit 66e8703

Please sign in to comment.