# Targets only instance2 because it's the only one where Snapshots can happenDescribe"$commandname Integration Tests"-Tag"IntegrationTests"{BeforeAll{Get-DbaProcess-SqlInstance$script:instance2|Where-ObjectProgram-matchdbatools|Stop-DbaProcess-Confirm:$false-WarningActionSilentlyContinue$server=Connect-DbaInstance-SqlInstance$script:instance2$db1="dbatoolsci_RemoveSnap"$db1_snap1="dbatoolsci_RemoveSnap_snapshotted1"$db1_snap2="dbatoolsci_RemoveSnap_snapshotted2"$db2="dbatoolsci_RemoveSnap2"$db2_snap1="dbatoolsci_RemoveSnap2_snapshotted"Remove-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1,$db2-Confirm:$falseGet-DbaDatabase-SqlInstance$script:instance2-Database$db1,$db2|Remove-DbaDatabase-Confirm:$false$server.Query("CREATE DATABASE $db1")$server.Query("CREATE DATABASE $db2")}AfterAll{Remove-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1,$db2-Confirm:$false-ErrorActionSilentlyContinueRemove-DbaDatabase-Confirm:$false-SqlInstance$script:instance2-Database$db1,$db2-ErrorActionSilentlyContinue}Context"Parameters validation"{It"Stops if no Database or AllDatabases"{{Remove-DbaDbSnapshot-SqlInstance$script:instance2-EnableException-WarningActionSilentlyContinue}|ShouldThrow"You must pipe"}It"Is nice by default"{{Remove-DbaDbSnapshot-SqlInstance$script:instance2*>$null}|ShouldNotThrow"You must pipe"}}

Context"Operations on snapshots"{BeforeEach{$null=New-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1-Name$db1_snap1-ErrorActionSilentlyContinue$null=New-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1-Name$db1_snap2-ErrorActionSilentlyContinue$null=New-DbaDbSnapshot-SqlInstance$script:instance2-Database$db2-Name$db2_snap1-ErrorActionSilentlyContinue}AfterEach{Remove-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1,$db2-Confirm:$false-ErrorActionSilentlyContinue}

It"Honors the Database parameter, dropping only snapshots of that database"{$results=Remove-DbaDbSnapshot-SqlInstance$script:instance2-Database$db1-Confirm:$false$results.Count|ShouldBe2$result=Remove-DbaDbSnapshot-SqlInstance$script:instance2-Database$db2-Confirm:$false$result.Name|ShouldBe$db2_snap1}