modified test code according to code review

This commit is contained in:
Zachary Folwick 2015-09-03 16:15:50 -07:00
parent 66d08dae08
commit 00e542524c

View file

@ -1,29 +1,37 @@
Describe "Test-Out-File" { Describe "Test-Out-File" {
$a = "some test text" $a = "some test text"
$b = New-Object psobject -Property @{text=$a} $b = New-Object psobject -Property @{text=$a}
$Testfile = "/tmp/outfileTest.txt" $testfile = "/tmp/outfileTest.txt"
BeforeEach { BeforeEach {
if (Test-Path -Path $testfile) if (Test-Path -Path $testfile)
{ {
Set-ItemProperty -Path $testfile -Name IsReadOnly -Value $false Remove-Item -Path $testfile -Force
rm $testfile
} }
} }
AfterEach { AfterEach {
# implement in *nix to remove test files after each test if they exist Remove-Item -Path $testfile -Force
rm $testfile
} }
It "Should be able to be called without error" { It "Should be able to be called without error" {
{ Out-File -FilePath $testfile } | Should Not Throw { Out-File -FilePath $testfile } | Should Not Throw
} }
It "Should be able to accept string input" { It "Should be able to accept string input via piping" {
{ $a | Out-File -FilePath $testfile } | Should Not Throw { $a | Out-File -FilePath $testfile } | Should Not Throw
$actual = Get-Content $testfile
$actual | Should Be $a
}
It "Should be able to accept string input via the InputObject swictch" {
{ Out-File -FilePath $testfile -InputObject $a } | Should Not Throw { Out-File -FilePath $testfile -InputObject $a } | Should Not Throw
$actual = Get-Content $testfile
$actual | Should Be $a
} }
It "Should be able to accept object input" { It "Should be able to accept object input" {