mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Modify Pester test for New-Object
This commit is contained in:
1 parent
0802c32562
commit
880225501a
1 file changed
+20
-25
@@ -1,39 +1,34 @@
|
|||||||
Describe "New-Object" {
|
Describe "New-Object" {
|
||||||
It "should create an object with 4 fields" {
|
It "should create an object with 4 fields" {
|
||||||
$o = New-Object psobject
|
$o = New-Object psobject
|
||||||
$val = $o.GetType()
|
$val = $o.GetType()
|
||||||
|
|
||||||
$val.IsPublic | Should Not BeNullOrEmpty
|
$val.IsPublic | Should Not BeNullOrEmpty
|
||||||
$val.Name | Should Not BeNullOrEmpty
|
$val.Name | Should Not BeNullOrEmpty
|
||||||
$val.IsSerializable | Should Not BeNullOrEmpty
|
$val.IsSerializable | Should Not BeNullOrEmpty
|
||||||
$val.BaseType | Should Not BeNullOrEmpty
|
$val.BaseType | Should Not BeNullOrEmpty
|
||||||
|
|
||||||
$val.IsPublic | Should Be $true
|
$val.IsPublic | Should Be $true
|
||||||
$val.IsSerializable | Should Be $false
|
$val.IsSerializable | Should Be $false
|
||||||
$val.Name | Should Be 'PSCustomObject'
|
$val.Name | Should Be 'PSCustomObject'
|
||||||
$val.BaseType | Should Be 'System.Object'
|
$val.BaseType | Should Be 'System.Object'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "should create an object with using Property switch" {
|
It "should create an object with using Property switch" {
|
||||||
$hash = @{
|
$hash = @{
|
||||||
FirstVal = 'test1'
|
FirstVal = 'test1'
|
||||||
SecondVal = 'test2'
|
SecondVal = 'test2'
|
||||||
}
|
}
|
||||||
$o = New-Object psobject -Property $hash
|
$o = New-Object psobject -Property $hash
|
||||||
|
|
||||||
$o.FirstVal | Should Be 'test1'
|
$o.FirstVal | Should Be 'test1'
|
||||||
$o.SecondVal | Should Be 'test2'
|
$o.SecondVal | Should Be 'test2'
|
||||||
}
|
}
|
||||||
|
|
||||||
It "should create a .Net object with using ArgumentList switch" {
|
It "should create a .Net object with using ArgumentList switch" {
|
||||||
$o = New-Object -TypeName System.Version -ArgumentList "1.2.3.4"
|
$o = New-Object -TypeName System.Version -ArgumentList "1.2.3.4"
|
||||||
$val = $o.GetType()
|
$o.GetType() | Should Be ([System.Version])
|
||||||
|
|
||||||
$o | Should Be "1.2.3.4"
|
$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'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user