Add Export-Clixml and Import-Clixml Pester Test
This commit is contained in:
parent
b19be8c911
commit
5c9ff45370
52
test/powershell/XMLCommand.Tests.ps1
Normal file
52
test/powershell/XMLCommand.Tests.ps1
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
Describe "XmlCommand DRT basic functionality Tests" -Tags DRT{
|
||||||
|
|
||||||
|
BeforeAll {
|
||||||
|
if(-not ([System.Management.Automation.PSTypeName]'IsHiddenTestType').Type)
|
||||||
|
{
|
||||||
|
Add-Type -TypeDefinition @"
|
||||||
|
public class IsHiddenTestType
|
||||||
|
{
|
||||||
|
public IsHiddenTestType()
|
||||||
|
{
|
||||||
|
Property1 = 1;
|
||||||
|
Property2 = "some string";
|
||||||
|
}
|
||||||
|
|
||||||
|
public IsHiddenTestType(int val, string data)
|
||||||
|
{
|
||||||
|
Property1 = val;
|
||||||
|
Property2 = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Property1;
|
||||||
|
public string Property2;
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BeforeEach {
|
||||||
|
$testfile = Join-Path -Path $TestDrive -ChildPath "clixml-directive.xml"
|
||||||
|
}
|
||||||
|
|
||||||
|
AfterEach {
|
||||||
|
rm $testfile
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Import with CliXml directive should work" -Skip:$IsOSX{
|
||||||
|
Get-Process | Export-Clixml $testfile
|
||||||
|
$results = Import-clixml $testfile
|
||||||
|
$results.Count | Should BeGreaterThan 0
|
||||||
|
$results[0].ToString().Contains("System.Diagnostics.Process") | Should Be $true
|
||||||
|
}
|
||||||
|
|
||||||
|
It "Import with Rehydration should work" -Skip:$IsOSX{
|
||||||
|
$property1 = 256
|
||||||
|
$property2 = "abcdef"
|
||||||
|
$isHiddenTestType = [IsHiddenTestType]::New($property1,$property2)
|
||||||
|
$isHiddenTestType | Export-Clixml $testfile
|
||||||
|
$results = Import-clixml $testfile
|
||||||
|
$results.Property1 | Should Be $property1
|
||||||
|
$results.Property2 | Should Be $property2
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue