Skip to content

Commit e935d93

Browse files
committed
Add refresh call verification in snapshot isolation tests
1 parent e0640f0 commit e935d93

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tests/Unit/Public/Disable-SqlDscDatabaseSnapshotIsolation.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Describe 'Disable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
9595

9696
$script:setSnapshotIsolationCalled = $false
9797
$script:setSnapshotIsolationValue = $null
98+
$script:refreshCalled = $false
9899

99100
$mockDatabaseObject | Add-Member -MemberType 'ScriptMethod' -Name 'SetSnapshotIsolation' -Value {
100101
param($Enable)
@@ -114,6 +115,7 @@ Describe 'Disable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
114115

115116
$mockDatabaseObject | Add-Member -MemberType 'ScriptMethod' -Name 'Refresh' -Value {
116117
# Mock implementation - in real SMO this updates properties from server
118+
$script:refreshCalled = $true
117119
} -Force
118120

119121
$mockServerObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Server'
@@ -153,10 +155,12 @@ Describe 'Disable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
153155
# Reset state for this test
154156
$mockDatabaseObject.SnapshotIsolationState = 'Enabled'
155157
$script:setSnapshotIsolationCalled = $false
158+
$script:refreshCalled = $false
156159

157160
$null = Disable-SqlDscDatabaseSnapshotIsolation -ServerObject $mockServerObject -Name 'TestDatabase' -Force -Refresh
158161

159162
$mockDatabaseObject.SnapshotIsolationState | Should -Be 'Disabled'
163+
$script:refreshCalled | Should -BeTrue -Because 'Refresh should be called when -Refresh is specified'
160164
}
161165
}
162166

tests/Unit/Public/Enable-SqlDscDatabaseSnapshotIsolation.Tests.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Describe 'Enable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
9595

9696
$script:setSnapshotIsolationCalled = $false
9797
$script:setSnapshotIsolationValue = $null
98+
$script:refreshCalled = $false
9899

99100
$mockDatabaseObject | Add-Member -MemberType 'ScriptMethod' -Name 'SetSnapshotIsolation' -Value {
100101
param($Enable)
@@ -114,6 +115,7 @@ Describe 'Enable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
114115

115116
$mockDatabaseObject | Add-Member -MemberType 'ScriptMethod' -Name 'Refresh' -Value {
116117
# Mock implementation - in real SMO this updates properties from server
118+
$script:refreshCalled = $true
117119
} -Force
118120

119121
$mockServerObject = New-Object -TypeName 'Microsoft.SqlServer.Management.Smo.Server'
@@ -153,10 +155,12 @@ Describe 'Enable-SqlDscDatabaseSnapshotIsolation' -Tag 'Public' {
153155
# Reset state for this test
154156
$mockDatabaseObject.SnapshotIsolationState = 'Disabled'
155157
$script:setSnapshotIsolationCalled = $false
158+
$script:refreshCalled = $false
156159

157160
$null = Enable-SqlDscDatabaseSnapshotIsolation -ServerObject $mockServerObject -Name 'TestDatabase' -Force -Refresh
158161

159162
$mockDatabaseObject.SnapshotIsolationState | Should -Be 'Enabled'
163+
$script:refreshCalled | Should -BeTrue -Because 'Refresh should be called when -Refresh is specified'
160164
}
161165
}
162166

0 commit comments

Comments
 (0)