Modify Pester test for New-Object

This commit is contained in:
TingLiu6
2016-03-24 20:20:06 -07:00
parent 0802c32562
commit 880225501a
+20 -25
View File
@@ -1,39 +1,34 @@
Describe "New-Object" {
It "should create an object with 4 fields" {
$o = New-Object psobject
$val = $o.GetType()
$o = New-Object psobject
$val = $o.GetType()
$val.IsPublic | Should Not BeNullOrEmpty
$val.Name | Should Not BeNullOrEmpty
$val.IsSerializable | Should Not BeNullOrEmpty
$val.BaseType | Should Not BeNullOrEmpty
$val.IsPublic | Should Not BeNullOrEmpty
$val.Name | Should Not BeNullOrEmpty
$val.IsSerializable | Should Not BeNullOrEmpty
$val.BaseType | Should Not BeNullOrEmpty
$val.IsPublic | Should Be $true
$val.IsSerializable | Should Be $false
$val.Name | Should Be 'PSCustomObject'
$val.BaseType | Should Be 'System.Object'
$val.IsPublic | Should Be $true
$val.IsSerializable | Should Be $false
$val.Name | Should Be 'PSCustomObject'
$val.BaseType | Should Be 'System.Object'
}
It "should create an object with using Property switch" {
$hash = @{
FirstVal = 'test1'
SecondVal = 'test2'
}
$o = New-Object psobject -Property $hash
$hash = @{
FirstVal = 'test1'
SecondVal = 'test2'
}
$o = New-Object psobject -Property $hash
$o.FirstVal | Should Be 'test1'
$o.SecondVal | Should Be 'test2'
$o.FirstVal | Should Be 'test1'
$o.SecondVal | Should Be 'test2'
}
It "should create a .Net object with using ArgumentList switch" {
$o = New-Object -TypeName System.Version -ArgumentList "1.2.3.4"
$val = $o.GetType()
$o = New-Object -TypeName System.Version -ArgumentList "1.2.3.4"
$o.GetType() | Should Be ([System.Version])
$o | Should Be "1.2.3.4"
$val.IsPublic | Should Be $true
$val.IsSerializable | Should Be $false
$val.Name | Should Be 'Version'
$val.BaseType | Should Be 'System.Object'
$o | Should Be "1.2.3.4"
}
}