Skip to content

Commit 0ada17e

Browse files
Slight improvement on coverage
1 parent 62a334b commit 0ada17e

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Tests/Unit/MSFT_KeyValuePairFile.Tests.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,44 @@ $($script:testAddedName)=$($script:testText)
773773
-Exactly 1
774774
}
775775
}
776+
777+
Context 'File exists and contains matching key that should not exist' {
778+
# verifiable (should be called) mocks
779+
Mock `
780+
-CommandName Assert-ParametersValid `
781+
-ModuleName 'MSFT_KeyValuePairFile' `
782+
-Verifiable
783+
784+
Mock `
785+
-CommandName Get-Content `
786+
-ParameterFilter { $path -eq $script:testTextFile } `
787+
-MockWith { $script:testFileExpectedTextContent } `
788+
-Verifiable
789+
790+
It 'Should not throw an exception' {
791+
{ $script:result = Test-TargetResource `
792+
-Path $script:testTextFile `
793+
-Name $script:testName `
794+
-Ensure 'Absent' `
795+
-Text $script:testText `
796+
-Verbose
797+
} | Should Not Throw
798+
}
799+
800+
It 'Should return false' {
801+
$script:result | Should Be $false
802+
}
803+
804+
It 'Should call the expected mocks' {
805+
Assert-VerifiableMocks
806+
Assert-MockCalled -CommandName Assert-ParametersValid -Exactly 1
807+
808+
Assert-MockCalled `
809+
-CommandName Get-Content `
810+
-ParameterFilter { $path -eq $script:testTextFile } `
811+
-Exactly 1
812+
}
813+
}
776814
}
777815
#endregion
778816

0 commit comments

Comments
 (0)