File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -246,6 +246,45 @@ Setting3.Test=Value4
246246
247247 # region Function Test-TargetResource
248248 Describe ' MSFT_ReplaceString\Test-TargetResource' {
249+ Context ' File exists and search text can not be found' {
250+ # verifiable (should be called) mocks
251+ Mock `
252+ - CommandName Assert-ParametersValid `
253+ - ModuleName ' MSFT_ReplaceText' `
254+ - Verifiable
255+
256+ Mock `
257+ - CommandName Get-Content `
258+ - ParameterFilter { $path -eq $script :testTextFile } `
259+ - MockWith { $script :testFileContent } `
260+ - Verifiable
261+
262+ $script :result = $null
263+
264+ It ' Should not throw an exception' {
265+ { $script :result = Test-TargetResource `
266+ - Path $script :testTextFile `
267+ - Search $script :testSearchNoFind `
268+ - Text $script :testTextReplace `
269+ - Verbose
270+ } | Should Not Throw
271+ }
272+
273+ It ' Should return true' {
274+ $script :result | Should Be $true
275+ }
276+
277+ It ' Should call the expected mocks' {
278+ Assert-VerifiableMocks
279+ Assert-MockCalled - CommandName Assert-ParametersValid - Exactly 1
280+
281+ Assert-MockCalled `
282+ - CommandName Get-Content `
283+ - ParameterFilter { $path -eq $script :testTextFile } `
284+ - Exactly 1
285+ }
286+ }
287+
249288 Context ' File exists and search text can be found but does not match replace string' {
250289 # verifiable (should be called) mocks
251290 Mock `
You can’t perform that action at this time.
0 commit comments