2016-03-04 23:48:30 +01:00
|
|
|
Describe "Get-Member" {
|
2015-07-15 19:15:39 +02:00
|
|
|
It "Should be able to be called on string objects, ints, arrays, etc" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$a = 1 #test numbers
|
|
|
|
$b = 1.3
|
|
|
|
$c = $false #test bools
|
|
|
|
$d = @(1,3) # test arrays
|
|
|
|
$e = "anoeduntodeu" #test strings
|
|
|
|
$f = 'asntoheusth' #test strings
|
2015-07-24 19:38:51 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
Get-Member -InputObject $a | Should Not BeNullOrEmpty
|
|
|
|
Get-Member -InputObject $b | Should Not BeNullOrEmpty
|
|
|
|
Get-Member -InputObject $c | Should Not BeNullOrEmpty
|
|
|
|
Get-Member -InputObject $d | Should Not BeNullOrEmpty
|
|
|
|
Get-Member -InputObject $e | Should Not BeNullOrEmpty
|
|
|
|
Get-Member -InputObject $f | Should Not BeNullOrEmpty
|
2015-07-15 19:15:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to extract a field from string objects, ints, arrays, etc" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$a = 1 #test numbers
|
|
|
|
$b = 1.3
|
|
|
|
$c = $false #test bools
|
|
|
|
$d = @(1,3) # test arrays
|
|
|
|
$e = "anoeduntodeu" #test strings
|
|
|
|
$f = 'asntoheusth' #test strings
|
2015-07-15 19:15:39 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
$a.GetType().Name | Should Be 'Int32'
|
|
|
|
$b.GetType().Name | Should Be 'Double'
|
|
|
|
$c.GetType().Name | Should Be 'Boolean'
|
|
|
|
$d.GetType().Name | Should Be 'Object[]'
|
|
|
|
$e.GetType().Name | Should Be 'String'
|
|
|
|
$f.GetType().Name | Should Be 'String'
|
2015-07-15 19:15:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Should be able to be called on a newly created PSObject" {
|
2016-03-04 23:52:27 +01:00
|
|
|
$o = New-Object psobject
|
|
|
|
# this creates a dependency on the Add-Member cmdlet.
|
|
|
|
Add-Member -InputObject $o -MemberType NoteProperty -Name proppy -Value "superVal"
|
2015-07-15 19:15:39 +02:00
|
|
|
|
2016-03-04 23:52:27 +01:00
|
|
|
Get-Member -InputObject $o | Should Not BeNullOrEmpty
|
2015-07-15 19:15:39 +02:00
|
|
|
}
|
2015-07-24 19:38:51 +02:00
|
|
|
}
|