File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments