Files
PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/XMLCommand.Tests.ps1
T
James Truher 1e1c4b7dc0 Restructure of pester test layout
This restructuring moves tests to a directory name which matches the module
in which the cmdlet resides which should improve the discoverability of a
specific test.
For tests which are not about cmdlets in a module, new directories have been
created to make those tests easier to find as well
2016-06-29 12:05:41 -07:00

53 lines
1.3 KiB
PowerShell

Describe "XmlCommand DRT basic functionality Tests" -Tags DRT{
BeforeAll {
if(-not ('IsHiddenTestType' -as "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 {
remove-item $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() | Should Match "System.Diagnostics.Process"
}
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
}
}