Fixed CR Issues

This commit is contained in:
TingLiu6 committed 2016-05-19 20:00:38 -07:00
1 parent b070320fb7
commit c2479d38b4
1 file changed
+6 -15
+6 -15
View File
@@ -5,18 +5,14 @@
$returnObject = $customPSObject | ConvertTo-Xml -Depth 1 $returnObject = $customPSObject | ConvertTo-Xml -Depth 1
$returnObject -is [System.Xml.XmlDocument] | Should Be $true $returnObject -is [System.Xml.XmlDocument] | Should Be $true
#$xml = [System.Xml.XmlDocument]$returnObject #$xml = [System.Xml.XmlDocument]$returnObject
$expectedValue = @" $expectedValue = '<?xml version="1.0" encoding="utf-8"?><Objects><Object Type="System.Management.Automation.PSCustomObject">' + '<Property Name="prop1" Type="System.String">val1</Property><Property Name="prop2" Type="System.String">val2</Property></Object></Objects>'
<?xml version="1.0" encoding="utf-8"?><Objects><Object Type="System.Management.Automation.PSCustomObject"><Property Name="prop1" Type="System.String">val1</Property><Property Name="prop2" Type="System.String">val2</Property></Object></Objects>
"@
$returnObject.OuterXml | Should Be $expectedValue $returnObject.OuterXml | Should Be $expectedValue
} }
It "Test convertto-xml with notypeinfo parameter" { It "Test convertto-xml with notypeinfo parameter" {
$returnObject = $customPSObject | ConvertTo-Xml -NoTypeInformation $returnObject = $customPSObject | ConvertTo-Xml -NoTypeInformation
$returnObject -is [System.Xml.XmlDocument] | Should Be $true $returnObject -is [System.Xml.XmlDocument] | Should Be $true
$expectedValue = @" $expectedValue = '<?xml version="1.0" encoding="utf-8"?><Objects><Object>' + '<Property Name="prop1">val1</Property><Property Name="prop2">val2</Property></Object></Objects>'
<?xml version="1.0" encoding="utf-8"?><Objects><Object><Property Name="prop1">val1</Property><Property Name="prop2">val2</Property></Object></Objects>
"@
$returnObject.OuterXml | Should Be $expectedValue $returnObject.OuterXml | Should Be $expectedValue
} }
@@ -33,29 +29,24 @@
It "Test convertto-xml as Stream" { It "Test convertto-xml as Stream" {
$returnObject = $customPSObject | ConvertTo-Xml -As Stream $returnObject = $customPSObject | ConvertTo-Xml -As Stream
$returnObject -is [System.Array] | Should Be $true $returnObject -is [System.Array] | Should Be $true
$stream1 = @" $stream1 = '<?xml version="1.0" encoding="utf-8"?>'
<?xml version="1.0" encoding="utf-8"?> $stream2 = '<Objects>'
"@
$stream2 = "<Objects>"
$stream3 = @" $stream3 = @"
<Object Type="System.Management.Automation.PSCustomObject">$newLine <Property Name="prop1" Type="System.String">val1</Property>$newLine <Property Name="prop2" Type="System.String">val2</Property>$newLine</Object> <Object Type="System.Management.Automation.PSCustomObject">$newLine <Property Name="prop1" Type="System.String">val1</Property>$newLine <Property Name="prop2" Type="System.String">val2</Property>$newLine</Object>
"@ "@
$stream4 = "</Objects>" $stream4 = '</Objects>'
$returnObject.Count | Should Be 4 $returnObject.Count | Should Be 4
$returnObject[0] | Should Be $stream1 $returnObject[0] | Should Be $stream1
$returnObject[1] | Should Be $stream2 $returnObject[1] | Should Be $stream2
$returnObject[2] | Should Be $stream3 $returnObject[2] | Should Be $stream3
$returnObject[3] | Should Be $stream4 $returnObject[3] | Should Be $stream4
} }
It "Test convertto-xml as Document" { It "Test convertto-xml as Document" {
$returnObject = $customPSObject | ConvertTo-Xml -As Document -NoTypeInformation $returnObject = $customPSObject | ConvertTo-Xml -As Document -NoTypeInformation
$returnObject -is [System.Xml.XmlDocument] | Should Be $true $returnObject -is [System.Xml.XmlDocument] | Should Be $true
$expectedValue = @" $expectedValue = '<?xml version="1.0" encoding="utf-8"?><Objects><Object><Property Name="prop1">val1</Property><Property Name="prop2">val2</Property></Object></Objects>'
<?xml version="1.0" encoding="utf-8"?><Objects><Object><Property Name="prop1">val1</Property><Property Name="prop2">val2</Property></Object></Objects>
"@
$returnObject.OuterXml | Should Be $expectedValue $returnObject.OuterXml | Should Be $expectedValue
} }
} }