@@ -488,6 +488,12 @@ $($script:testAddedName)=$($script:testText)
488488 - ModuleName ' DSR_KeyValuePairFile' `
489489 - Verifiable
490490
491+ Mock `
492+ - CommandName Test-Path `
493+ - ModuleName ' DSR_KeyValuePairFile' `
494+ - MockWith { $true } `
495+ - Verifiable
496+
491497 Mock `
492498 - CommandName Get-Content `
493499 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -526,6 +532,12 @@ $($script:testAddedName)=$($script:testText)
526532 - ModuleName ' DSR_KeyValuePairFile' `
527533 - Verifiable
528534
535+ Mock `
536+ - CommandName Test-Path `
537+ - ModuleName ' DSR_KeyValuePairFile' `
538+ - MockWith { $true } `
539+ - Verifiable
540+
529541 Mock `
530542 - CommandName Get-Content `
531543 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -563,6 +575,12 @@ $($script:testAddedName)=$($script:testText)
563575 - ModuleName ' DSR_KeyValuePairFile' `
564576 - Verifiable
565577
578+ Mock `
579+ - CommandName Test-Path `
580+ - ModuleName ' DSR_KeyValuePairFile' `
581+ - MockWith { $true } `
582+ - Verifiable
583+
566584 Mock `
567585 - CommandName Get-Content `
568586 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -601,6 +619,12 @@ $($script:testAddedName)=$($script:testText)
601619 - ModuleName ' DSR_KeyValuePairFile' `
602620 - Verifiable
603621
622+ Mock `
623+ - CommandName Test-Path `
624+ - ModuleName ' DSR_KeyValuePairFile' `
625+ - MockWith { $true } `
626+ - Verifiable
627+
604628 Mock `
605629 - CommandName Get-Content `
606630 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -640,6 +664,12 @@ $($script:testAddedName)=$($script:testText)
640664 - ModuleName ' DSR_KeyValuePairFile' `
641665 - Verifiable
642666
667+ Mock `
668+ - CommandName Test-Path `
669+ - ModuleName ' DSR_KeyValuePairFile' `
670+ - MockWith { $true } `
671+ - Verifiable
672+
643673 Mock `
644674 - CommandName Get-Content `
645675 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -679,6 +709,12 @@ $($script:testAddedName)=$($script:testText)
679709 - ModuleName ' DSR_KeyValuePairFile' `
680710 - Verifiable
681711
712+ Mock `
713+ - CommandName Test-Path `
714+ - ModuleName ' DSR_KeyValuePairFile' `
715+ - MockWith { $true } `
716+ - Verifiable
717+
682718 Mock `
683719 - CommandName Get-Content `
684720 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -718,6 +754,12 @@ $($script:testAddedName)=$($script:testText)
718754 - ModuleName ' DSR_KeyValuePairFile' `
719755 - Verifiable
720756
757+ Mock `
758+ - CommandName Test-Path `
759+ - ModuleName ' DSR_KeyValuePairFile' `
760+ - MockWith { $true } `
761+ - Verifiable
762+
721763 Mock `
722764 - CommandName Get-Content `
723765 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -756,6 +798,12 @@ $($script:testAddedName)=$($script:testText)
756798 - ModuleName ' DSR_KeyValuePairFile' `
757799 - Verifiable
758800
801+ Mock `
802+ - CommandName Test-Path `
803+ - ModuleName ' DSR_KeyValuePairFile' `
804+ - MockWith { $true } `
805+ - Verifiable
806+
759807 Mock `
760808 - CommandName Get-Content `
761809 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -764,12 +812,12 @@ $($script:testAddedName)=$($script:testText)
764812
765813 It ' Should not throw an exception' {
766814 { $script :result = Test-TargetResource `
767- - Path $script :testTextFile `
768- - Name $script :testName `
769- - Ensure ' Present' `
770- - Text $script :testText.ToUpper () `
771- - IgnoreValueCase:$true `
772- - Verbose
815+ - Path $script :testTextFile `
816+ - Name $script :testName `
817+ - Ensure ' Present' `
818+ - Text $script :testText.ToUpper () `
819+ - IgnoreValueCase:$true `
820+ - Verbose
773821 } | Should -Not - Throw
774822 }
775823
@@ -795,6 +843,12 @@ $($script:testAddedName)=$($script:testText)
795843 - ModuleName ' DSR_KeyValuePairFile' `
796844 - Verifiable
797845
846+ Mock `
847+ - CommandName Test-Path `
848+ - ModuleName ' DSR_KeyValuePairFile' `
849+ - MockWith { $true } `
850+ - Verifiable
851+
798852 Mock `
799853 - CommandName Get-Content `
800854 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -830,8 +884,14 @@ $($script:testAddedName)=$($script:testText)
830884
831885 # region Function Assert-ParametersValid
832886 Describe ' DSR_KeyValuePairFile\Assert-ParametersValid' {
833- Context ' File exists' {
887+ Context ' File parent path exists' {
834888 # verifiable (should be called) mocks
889+ Mock `
890+ - CommandName Split-Path `
891+ - ParameterFilter { $path -eq $script :testTextFile } `
892+ - MockWith { $script :testTextFile } `
893+ - Verifiable
894+
835895 Mock `
836896 - CommandName Test-Path `
837897 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -840,9 +900,9 @@ $($script:testAddedName)=$($script:testText)
840900
841901 It ' Should not throw an exception' {
842902 { Assert-ParametersValid `
843- - Path $script :testTextFile `
844- - Name $script :testName `
845- - Verbose
903+ - Path $script :testTextFile `
904+ - Name $script :testName `
905+ - Verbose
846906 } | Should -Not - Throw
847907 }
848908
@@ -852,8 +912,14 @@ $($script:testAddedName)=$($script:testText)
852912 }
853913 }
854914
855- Context ' File does not exist' {
915+ Context ' File parent path does not exist' {
856916 # verifiable (should be called) mocks
917+ Mock `
918+ - CommandName Split-Path `
919+ - ParameterFilter { $path -eq $script :testTextFile } `
920+ - MockWith { $script :testTextFile } `
921+ - Verifiable
922+
857923 Mock `
858924 - CommandName Test-Path `
859925 - ParameterFilter { $path -eq $script :testTextFile } `
@@ -866,9 +932,9 @@ $($script:testAddedName)=$($script:testText)
866932
867933 It ' Should throw expected exception' {
868934 { Assert-ParametersValid `
869- - Path $script :testTextFile `
870- - Name $script :testName `
871- - Verbose
935+ - Path $script :testTextFile `
936+ - Name $script :testName `
937+ - Verbose
872938 } | Should - Throw $errorRecord
873939 }
874940
0 commit comments