Add Update-TypeData and Update-FormatData Pester Unit Test

This commit is contained in:
JumpingYang001 committed 2016-05-16 19:52:47 -07:00
1 parent 357f38f26d
commit 97ded9ca80
2 files changed
+394 -30

No files matched your search

+50 -15
View File
@@ -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
}
}
}