mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add Update-TypeData and Update-FormatData Pester Unit Test
This commit is contained in:
1 parent
357f38f26d
commit
97ded9ca80
2 files changed
+394
-30
No files matched your search
@@ -1,15 +1,50 @@
|
||||
Describe "Update-FormatData" {
|
||||
|
||||
Context "Validate Update-FormatData update correctly" {
|
||||
|
||||
It "Should not throw upon reloading previous formatting file" {
|
||||
{ Update-FormatData } | Should Not throw
|
||||
}
|
||||
|
||||
It "Should validly load formatting data" {
|
||||
{ Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path "outputfile.ps1xml" }
|
||||
{ Update-FormatData -prependPath "outputfile.ps1xml" | Should Not throw }
|
||||
{ Remove-Item "outputfile.ps1xml" -ErrorAction SilentlyContinue }
|
||||
}
|
||||
}
|
||||
}
|
||||
Describe "Update-FormatData" {
|
||||
|
||||
Context "Validate Update-FormatData update correctly" {
|
||||
|
||||
It "Should not throw upon reloading previous formatting file" {
|
||||
{ Update-FormatData } | Should Not throw
|
||||
}
|
||||
|
||||
It "Should validly load formatting data" {
|
||||
{ Get-FormatData -typename System.Diagnostics.Process | Export-FormatData -Path "outputfile.ps1xml" }
|
||||
{ Update-FormatData -prependPath "outputfile.ps1xml" | Should Not throw }
|
||||
{ Remove-Item "outputfile.ps1xml" -ErrorAction SilentlyContinue }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Update-FormatData basic functionality" -Tags DRT{
|
||||
$tmpDirectory = $TestDrive
|
||||
$testfilename = "testfile.ps1xml"
|
||||
$testfile = Join-Path -Path $tmpDirectory -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>
|
||||
"@
|
||||
$xmlContent>$testfile
|
||||
try
|
||||
{
|
||||
{Update-FormatData -Append $testfile -WhatIf} | Should Not Throw
|
||||
{Update-FormatData -Prepend $testfile -WhatIf} | Should Not Throw
|
||||
}
|
||||
finally
|
||||
{
|
||||
rm $testfile
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user