2016-04-26 08:46:16 +02:00
|
|
|
Describe "Update-FormatData" {
|
|
|
|
|
2016-05-24 00:04:13 +02:00
|
|
|
BeforeAll {
|
|
|
|
$path = Join-Path -Path $TestDrive -ChildPath "outputfile.ps1xml"
|
|
|
|
$ps = [powershell]::Create()
|
|
|
|
$iss = [system.management.automation.runspaces.initialsessionstate]::CreateDefault2()
|
|
|
|
$rs = [system.management.automation.runspaces.runspacefactory]::CreateRunspace($iss)
|
|
|
|
$rs.Open()
|
|
|
|
$ps.Runspace = $rs
|
|
|
|
}
|
|
|
|
AfterAll {
|
|
|
|
$rs.Close()
|
|
|
|
$ps.Dispose()
|
|
|
|
}
|
2016-04-26 08:46:16 +02:00
|
|
|
Context "Validate Update-FormatData update correctly" {
|
|
|
|
|
2016-05-10 11:07:29 +02:00
|
|
|
It "Should not throw upon reloading previous formatting file" {
|
|
|
|
{ Update-FormatData } | Should Not throw
|
|
|
|
}
|
2016-04-26 08:46:16 +02:00
|
|
|
|
2016-05-10 11:07:29 +02:00
|
|
|
It "Should validly load formatting data" {
|
|
|
|
Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path $path
|
2016-05-24 00:04:13 +02:00
|
|
|
$null = $ps.AddScript("Update-FormatData -prependPath $path")
|
|
|
|
$ps.Invoke()
|
|
|
|
$ps.HadErrors | Should be $false
|
2016-05-10 11:07:29 +02:00
|
|
|
}
|
2016-04-26 08:46:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Describe "Update-FormatData basic functionality" -Tags DRT{
|
2016-05-24 00:04:13 +02:00
|
|
|
BeforeAll {
|
|
|
|
$testfilename = "testfile.ps1xml"
|
|
|
|
$testfile = Join-Path -Path $TestDrive -ChildPath $testfilename
|
|
|
|
|
2016-04-26 08:46:16 +02:00
|
|
|
$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 11:07:29 +02:00
|
|
|
$xmlContent > $testfile
|
2016-05-24 00:04:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It "Update-FormatData with WhatIf should work"{
|
|
|
|
|
|
|
|
{ Update-FormatData -Append $testfile -WhatIf } | Should Not Throw
|
|
|
|
{ Update-FormatData -Prepend $testfile -WhatIf } | Should Not Throw
|
2016-04-26 08:46:16 +02:00
|
|
|
}
|
2016-05-24 00:04:13 +02:00
|
|
|
}
|