mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add Format-Custom,Format-List,Format-Wide Pester Test
This commit is contained in:
1 parent
8dd69bd55a
commit
506ae5d899
3 files changed
+138
No files matched your search
@@ -23,3 +23,22 @@ Describe "Format-Custom" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Describe "Format-Custom DRT basic functionality" -Tags DRT{
|
||||
It "Format-Custom with subobject should work"{
|
||||
$expectResult1 = "this is the name"
|
||||
$expectResult2 = "this is the name of the sub object"
|
||||
$testObject = @{}
|
||||
$testObject.name = $expectResult1
|
||||
$testObject.subObjectValue = @{}
|
||||
$testObject.subObjectValue.name = $expectResult2
|
||||
$testObject.subObjectValue.array = (0..63)
|
||||
$testObject.subObjectValue.stringarray = @("one","two")
|
||||
$result = $testObject | Format-Custom | Out-String
|
||||
$result | Should Match $expectResult1
|
||||
$result | Should Match $expectResult2
|
||||
$result | Should Match "one"
|
||||
$result | Should Match "two"
|
||||
}
|
||||
}
|
||||
@@ -66,3 +66,65 @@ Describe "Format-List" {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Format-List DRT basic functionality" -Tags DRT{
|
||||
It "Format-List with array should work"{
|
||||
$al = (0..255)
|
||||
$info = @{}
|
||||
$info.array = $al
|
||||
$result = $info | Format-List | Out-String
|
||||
$result | Should Match "Name : array\s+Value : {0, 1, 2, 3...}"
|
||||
}
|
||||
|
||||
It "Format-List with No Objects for End-To-End should work"{
|
||||
$p = @{}
|
||||
$result = $p | Format-List -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Format-List with Null Objects for End-To-End should work"{
|
||||
$p = $null
|
||||
$result = $p | Format-List -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-List with single line string for End-To-End should work" -pending{
|
||||
$p = "single line string"
|
||||
$result = $p | Format-List -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-List with multiple line string for End-To-End should work" -pending{
|
||||
$p = "Line1\nLine2"
|
||||
$result = $p | Format-List -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#pending on issue#900
|
||||
It "Format-List with string sequence for End-To-End should work" -pending{
|
||||
$p = "Line1","Line2"
|
||||
$result = $p | Format-List -Property "foo","bar" | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Format-List with complex object for End-To-End should work"{
|
||||
Add-Type -TypeDefinition "public enum MyDayOfWeek{Sun,Mon,Tue,Wed,Thr,Fri,Sat}"
|
||||
$eto = New-Object MyDayOfWeek
|
||||
$info = @{}
|
||||
$info.intArray = 1,2,3,4
|
||||
$info.arrayList = "string1","string2"
|
||||
$info.enumerable = [MyDayOfWeek]$eto
|
||||
$info.enumerableTestObject = $eto
|
||||
$result = $info|Format-List|Out-String
|
||||
$result | Should Match "Name : enumerableTestObject"
|
||||
$result | Should Match "Value : Sun"
|
||||
$result | Should Match "Name : arrayList"
|
||||
$result | Should Match "Value : {string1, string2}"
|
||||
$result | Should Match "Name : enumerable"
|
||||
$result | Should Match "Value : Sun"
|
||||
$result | Should Match "Name : intArray"
|
||||
$result | Should Match "Value : {1, 2, 3, 4}"
|
||||
}
|
||||
}
|
||||
@@ -31,3 +31,60 @@ Describe "Format-Wide" {
|
||||
{ Format-Wide -InputObject $(gps) -View aoeu } | Should Throw
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Format-Wide DRT basic functionality" -Tags DRT{
|
||||
It "Format-Wide with array should work"{
|
||||
$al = (0..255)
|
||||
$info = @{}
|
||||
$info.array = $al
|
||||
$result = $info | Format-Wide | Out-String
|
||||
$result | Should Match "array"
|
||||
}
|
||||
|
||||
It "Format-Wide with No Objects for End-To-End should work"{
|
||||
$p = @{}
|
||||
$result = $p | Format-Wide | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Format-Wide with Null Objects for End-To-End should work"{
|
||||
$p = $null
|
||||
$result = $p | Format-Wide | Out-String
|
||||
$result | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Format-Wide with single line string for End-To-End should work"{
|
||||
$p = "single line string"
|
||||
$result = $p | Format-Wide | Out-String
|
||||
$result | Should Match $p
|
||||
}
|
||||
|
||||
It "Format-Wide with multiple line string for End-To-End should work"{
|
||||
$p = "Line1\nLine2"
|
||||
$result = $p | Format-Wide | Out-String
|
||||
$result | Should Match "Line1"
|
||||
$result | Should Match "Line2"
|
||||
}
|
||||
|
||||
It "Format-Wide with string sequence for End-To-End should work"{
|
||||
$p = "Line1","Line2"
|
||||
$result = $p |Format-Wide | Out-String
|
||||
$result | Should Match "Line1"
|
||||
$result | Should Match "Line2"
|
||||
}
|
||||
|
||||
It "Format-Wide with complex object for End-To-End should work"{
|
||||
Add-Type -TypeDefinition "public enum MyDayOfWeek{Sun,Mon,Tue,Wed,Thr,Fri,Sat}"
|
||||
$eto = New-Object MyDayOfWeek
|
||||
$info = @{}
|
||||
$info.intArray = 1,2,3,4
|
||||
$info.arrayList = "string1","string2"
|
||||
$info.enumerable = [MyDayOfWeek]$eto
|
||||
$info.enumerableTestObject = $eto
|
||||
$result = $info|Format-Wide|Out-String
|
||||
$result | Should Match "intArray"
|
||||
$result | Should Match "arrayList"
|
||||
$result | Should Match "enumerable"
|
||||
$result | Should Match "enumerableTestObject"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user