mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Add DisplayXMLTest to Pester Unit Test
This commit is contained in:
1 parent
58425bbcc0
commit
c87dac7ba0
2 files changed
+48
No files matched your search
@@ -124,4 +124,36 @@ Describe "Format-List DRT basic functionality" -Tags DRT{
|
||||
$result | Should Match "Name : intArray"
|
||||
$result | Should Match "Value : {1, 2, 3, 4}"
|
||||
}
|
||||
|
||||
It "Format-List with multiple same class object should work"{
|
||||
Add-Type -TypeDefinition "public class TestClass{public TestClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;}"
|
||||
$testobject1 = New-Object TestClass 'name1',1
|
||||
$testobject2 = New-Object TestClass 'name2',2
|
||||
$testobject3 = New-Object TestClass 'name3',3
|
||||
$testobjects = @($testobject1,$testobject2,$testobject3)
|
||||
$result = $testobjects|Format-List|Out-String
|
||||
$result | Should Match "Name : name1"
|
||||
$result | Should Match "Length : 1"
|
||||
$result | Should Match "Name : name2"
|
||||
$result | Should Match "Length : 2"
|
||||
$result | Should Match "Name : name3"
|
||||
$result | Should Match "Length : 3"
|
||||
}
|
||||
|
||||
It "Format-List with multiple different class object should work"{
|
||||
Add-Type -TypeDefinition "public class TestClass{public TestClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;}"
|
||||
Add-Type -TypeDefinition "public class TestClass2{public TestClass2(string name,string value,int length){Name = name;Value = value; Length = length;}public string Name;public string Value;public int Length;}"
|
||||
$testobject1 = New-Object TestClass 'name1',1
|
||||
$testobject2 = New-Object TestClass2 'name2',"value2",2
|
||||
$testobject3 = New-Object TestClass 'name3',3
|
||||
$testobjects = @($testobject1,$testobject2,$testobject3)
|
||||
$result = $testobjects|Format-List|Out-String
|
||||
$result | Should Match "Name : name1"
|
||||
$result | Should Match "Length : 1"
|
||||
$result | Should Match "Name : name2"
|
||||
$result | Should Match "Value : value2"
|
||||
$result | Should Match "Length : 2"
|
||||
$result | Should Match "Name : name3"
|
||||
$result | Should Match "Length : 3"
|
||||
}
|
||||
}
|
||||
@@ -94,4 +94,20 @@ Describe "Format-Wide DRT basic functionality" -Tags DRT{
|
||||
$result | Should Match "enumerable"
|
||||
$result | Should Match "enumerableTestObject"
|
||||
}
|
||||
|
||||
It "Format-Wide with multiple same class object with grouping should work"{
|
||||
Add-Type -TypeDefinition "public class TestGroupingClass{public TestGroupingClass(string name,int length){Name = name;Length = length;}public string Name;public int Length;public string GroupingKey;}"
|
||||
$testobject1 = New-Object TestGroupingClass 'name1',1
|
||||
$testobject1.GroupingKey = "foo"
|
||||
$testobject2 = New-Object TestGroupingClass 'name2',2
|
||||
$testobject1.GroupingKey = "bar"
|
||||
$testobject3 = New-Object TestGroupingClass 'name3',3
|
||||
$testobject1.GroupingKey = "bar"
|
||||
$testobjects = @($testobject1,$testobject2,$testobject3)
|
||||
$result = $testobjects|Format-Wide -GroupBy GroupingKey|Out-String
|
||||
$result | Should Match "GroupingKey: bar"
|
||||
$result | Should Match "name1"
|
||||
$result | Should Match " GroupingKey:"
|
||||
$result | Should Match "name2\s+name3"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user