File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed
Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change @@ -79,24 +79,17 @@ Describe 'Test-SqlDscIsDatabase' -Tag 'Public' {
7979 }
8080
8181 It ' Should call Refresh when Refresh parameter is specified' {
82- Mock - CommandName Write-Verbose
83-
84- $refreshCalled = $false
85-
86- $mockServerObjectWithRefresh = New-Object - TypeName ' Microsoft.SqlServer.Management.Smo.Server'
87- $mockServerObjectWithRefresh | Add-Member - MemberType ' NoteProperty' - Name ' InstanceName' - Value ' TestInstance' - Force
88- $mockServerObjectWithRefresh | Add-Member - MemberType ' ScriptProperty' - Name ' Databases' - Value {
89- return @ {
90- ' TestDatabase' = $mockExistingDatabase
91- } | Add-Member - MemberType ' ScriptMethod' - Name ' Refresh' - Value {
92- # This will be verified by checking if Refresh was called
93- } - PassThru - Force
94- } - Force
82+ Mock - CommandName Get-SqlDscDatabase - MockWith {
83+ return $mockExistingDatabase
84+ }
9585
96- $result = Test-SqlDscIsDatabase - ServerObject $mockServerObjectWithRefresh - Name ' TestDatabase' - Refresh
86+ $result = Test-SqlDscIsDatabase - ServerObject $mockServerObject - Name ' TestDatabase' - Refresh
9787
9888 $result | Should - BeTrue
99- # We can verify Refresh was called by the fact that no error was thrown and the command completed successfully
89+
90+ Should - Invoke - CommandName Get-SqlDscDatabase - ParameterFilter {
91+ $Refresh -eq $true
92+ } - Exactly - Times 1 - Scope It
10093 }
10194
10295 It ' Should support pipeline input' {
You can’t perform that action at this time.
0 commit comments