Add Unit Test For Write Command
This commit is contained in:
parent
52d747e56b
commit
97c00e6343
23
test/powershell/Write-Debug.Tests.ps1
Normal file
23
test/powershell/Write-Debug.Tests.ps1
Normal file
|
@ -0,0 +1,23 @@
|
|||
Describe "Write-Debug DRT Unit Tests" -Tags DRT{
|
||||
function unittest-writedebugline
|
||||
{
|
||||
Write-Host ""
|
||||
Write-Host "foo"
|
||||
Write-Host "hello" -ForegroundColor Black -BackgroundColor Cyan
|
||||
Write-Debug "this is a test"
|
||||
}
|
||||
|
||||
It "Write-Debug Test" {
|
||||
$o = "this is a test"
|
||||
{ Write-Debug $o } | Should Not Throw
|
||||
}
|
||||
|
||||
It "Write-Debug Test2" {
|
||||
{ $debugpreference='continue'; Write-Debug 'hello' } | Should Not Throw
|
||||
$debugpreference ='SilentlyContinue'
|
||||
}
|
||||
|
||||
It "Write-Debug Test3" {
|
||||
{ unittest-writedebugline } | Should Not Throw
|
||||
}
|
||||
}
|
|
@ -30,8 +30,8 @@ Describe "Write-Error DRT Unit Tests" -Tags DRT{
|
|||
$Error[0].InvocationInfo.MyCommand.Name | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
# Skip with issue #846
|
||||
It "Should be works with all parameters" -Pending {
|
||||
#Blocked by issue #846
|
||||
It "Should be works with all parameters" -Pending {
|
||||
$exception = New-Object -TypeName System.ArgumentNullException -ArgumentList paramname
|
||||
Write-Error -Message myerrortext -Exception $exception -ErrorId myerrorid -Category syntaxerror -TargetObject TargetObject -CategoryActivity myactivity -CategoryReason myreason -CategoryTargetName mytargetname -CategoryTargetType mytargettype -RecommendedAction myrecommendedaction -ErrorAction SilentlyContinue
|
||||
$Error[0] | Should Not BeNullOrEmpty
|
||||
|
@ -68,6 +68,16 @@ Describe "Write-Error DRT Unit Tests" -Tags DRT{
|
|||
$Error[0].InvocationInfo | Should Not BeNullOrEmpty
|
||||
$Error[0].InvocationInfo.MyCommand.Name | Should BeNullOrEmpty
|
||||
}
|
||||
|
||||
#Blocked by issue #846
|
||||
It "Should be works with all parameters" -Pending {
|
||||
write-error -Activity fooAct -Reason fooReason -TargetName fooTargetName -TargetType fooTargetType -Message fooMessage
|
||||
$Error[0].CategoryInfo.Activity | Should Be 'fooAct'
|
||||
$Error[0].CategoryInfo.Reason | Should Be 'fooReason'
|
||||
$Error[0].CategoryInfo.TargetName | Should Be 'fooTargetName'
|
||||
$Error[0].CategoryInfo.TargetType | Should Be 'fooTargetType'
|
||||
$Error[0].CategoryInfo.GetMessage() | Should Be 'NotSpecified: (fooTargetName:fooTargetType) [fooAct], fooReason'
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Write-Error" {
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
Describe "Write-Output DRT Unit Tests" -Tags DRT{
|
||||
It "Simple Write Object Test" {
|
||||
$objectWritten = 1, 2.2, @("John", "Smith", 10), "abc"
|
||||
$results = Write-Output $objectWritten
|
||||
$results.Length | Should Be $objectWritten.Length
|
||||
|
||||
$results[0] | Should Be $objectWritten[0]
|
||||
$results[1] | Should Be $objectWritten[1]
|
||||
|
||||
$results[2] | Should Be $objectWritten[2]
|
||||
$results[2] -is [System.Array] | Should Be $true
|
||||
|
||||
$results[3] | Should Be $objectWritten[3]
|
||||
$results[3] -is [System.String] | Should Be $true
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Write-Output" {
|
||||
$testString = $testString
|
||||
Context "Input Tests" {
|
||||
|
|
Loading…
Reference in a new issue