Files
PowerShell/test/powershell/Update-FormatData.Tests.ps1
T

50 lines
1.7 KiB
PowerShell
Raw Normal View History

Describe "Update-FormatData" {
Context "Validate Update-FormatData update correctly" {
2016-05-10 02:07:29 -07:00
It "Should not throw upon reloading previous formatting file" {
{ Update-FormatData } | Should Not throw
}
2016-05-10 02:07:29 -07:00
It "Should validly load formatting data" {
$path = Join-Path -Path $TestDrive -ChildPath "outputfile.ps1xml"
Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path $path
{ Update-FormatData -prependPath $path } | Should Not throw
Remove-Item $path -ErrorAction SilentlyContinue
}
}
}
Describe "Update-FormatData basic functionality" -Tags DRT{
$testfilename = "testfile.ps1xml"
2016-05-10 02:07:29 -07:00
$testfile = Join-Path -Path $TestDrive -ChildPath $testfilename
It "Update-FormatData with WhatIf should work"{
$xmlContent=@"
<Types>
<Type>
<Name>AnyName</Name>
<Members>
<PropertySet>
<Name>PropertySetName</Name>
<ReferencedProperties>
<Name>FirstName</Name>
<Name>LastName</Name>
</ReferencedProperties>
</PropertySet>
</Members>
</Type>
</Types>
"@
2016-05-10 02:07:29 -07:00
$xmlContent > $testfile
try
{
2016-05-10 02:07:29 -07:00
{ Update-FormatData -Append $testfile -WhatIf } | Should Not Throw
{ Update-FormatData -Prepend $testfile -WhatIf } | Should Not Throw
}
finally
{
2016-05-10 02:07:29 -07:00
Remove-Item $testfile -ErrorAction SilentlyContinue
}
}
}