From 7b0ba909f17b18a0f3e2c4d9e5a20ceeae5ae18c Mon Sep 17 00:00:00 2001 From: Johan Ljunggren Date: Tue, 12 May 2020 19:25:38 +0200 Subject: [PATCH] BREAKING CHANGE: SqlServerDsc: Removed resource SqlDatabaseRecoveryModel (#1541) - SqlDatabaseRecoveryModel - This resource is now deprecated. The functionality is now covered by a property in the resource SqlDatabase (issue #967). --- CHANGELOG.md | 8 +- README.md | 40 +-- build.yaml | 3 + codecov.yml | 1 + .../MSFT_SqlDatabaseRecoveryModel.psm1} | 9 + .../MSFT_SqlDatabaseRecoveryModel.schema.mof} | 2 +- ...SFT_SqlDatabaseRecoveryModel.strings.psd1} | 4 +- source/Examples/README.md | 1 - .../1-SetDatabaseRecoveryModel.ps1 | 60 ---- .../DSC_SqlDatabaseRecoveryModel.Tests.ps1 | 275 ------------------ 10 files changed, 30 insertions(+), 373 deletions(-) rename source/DSCResources/{DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 => MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1} (97%) rename source/DSCResources/{DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.schema.mof => MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof} (90%) rename source/DSCResources/{DSC_SqlDatabaseRecoveryModel/en-US/DSC_SqlDatabaseRecoveryModel.strings.psd1 => MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1} (62%) delete mode 100644 source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 delete mode 100644 tests/Unit/DSC_SqlDatabaseRecoveryModel.Tests.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 72b67cd7b..adf035d17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,10 @@ in a future release. the resources _SqlServerProtocol_ and _SqlServerProtocolTcpIp_. - SqlDatabaseOwner - This resource is now deprecated. The functionality is now covered by - the resources _SqlDatabase_ ([issue #966](https://github.com/dsccommunity/SqlServerDsc/issues/966)). + a property in the resource _SqlDatabase_ ([issue #966](https://github.com/dsccommunity/SqlServerDsc/issues/966)). +- SqlDatabaseRecoveryModel + - This resource is now deprecated. The functionality is now covered by + a property in the resource _SqlDatabase_ ([issue #967](https://github.com/dsccommunity/SqlServerDsc/issues/967)). ### Added @@ -75,6 +78,9 @@ in a future release. - BREAKING CHANGE: The parameter `ServerName` is now non-mandatory and defaults to `$env:COMPUTERNAME` ([issue #319](https://github.com/dsccommunity/SqlServerDsc/issues/319)). - Normalize parameter descriptive text for default values. +- SqlDatabaseOwner + - BREAKING CHANGE: Database changed to DatabaseName for consistency with + other modules ([issue #1484](https://github.com/dsccommunity/SqlServerDsc/issues/1484)). - SqlDatabasePermission - BREAKING CHANGE: The parameter `ServerName` is now non-mandatory and defaults to `$env:COMPUTERNAME` ([issue #319](https://github.com/dsccommunity/SqlServerDsc/issues/319)). diff --git a/README.md b/README.md index 4362b7de9..0bc9dd5ea 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ for these deprecated resources. These resources will be removed in a future release. * SqlDatabaseOwner _(replaced by a property in [**SqlDatabase**](#sqldatabase)_. +* SqlDatabaseRecoveryModel _(replaced by a property in [**SqlDatabase**](#sqldatabase)_. * SqlServerNetwork _(replaced by [**SqlServerProtocol**](#sqlserverprotocol) and_ _[**SqlServerProtocolTcpIp**](#sqlserverprotocoltcpip))_. @@ -100,8 +101,6 @@ in a future release. to manage default locations for Data, Logs, and Backups for SQL Server * [**SqlDatabasePermission**](#sqldatabasepermission) resource to manage SQL database permissions. -* [**SqlDatabaseRecoveryModel**](#sqldatabaserecoverymodel) resource - to manage database recovery model. * [**SqlDatabaseRole**](#sqldatabaserole) resource to manage SQL database roles. * [**SqlDatabaseUser**](#sqldatabaseuser) resource to manage SQL database users. * [**SqlRS**](#sqlrs) configures SQL Server Reporting. @@ -586,6 +585,12 @@ This resource is used to create or delete a database. For more information about SQL Server databases, please read the following articles [Create a Database](https://docs.microsoft.com/en-us/sql/relational-databases/databases/create-a-database) and [Delete a Database](https://docs.microsoft.com/en-us/sql/relational-databases/databases/delete-a-database). +This resource set the recovery model for a database. The recovery model controls +how transactions are logged, whether the transaction log requires (and allows) +backing up, and what kinds of restore operations are available. Three recovery +models exist: full, simple, and bulk-logged. Read more about recovery model in +the article [View or Change the Recovery Model of a Database](https://msdn.microsoft.com/en-us/library/ms189272.aspx). + #### Requirements * Target machine must be running Windows Server 2008 R2 or later. @@ -704,37 +709,6 @@ will also get their permission revoked. All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabasePermission). -### SqlDatabaseRecoveryModel - -This resource set the recovery model for a database. The recovery model controls -how transactions are logged, whether the transaction log requires (and allows) -backing up, and what kinds of restore operations are available. -Three recovery models exist: full, simple, and bulk-logged. -Read more about recovery model in this article -[View or Change the Recovery Model of a Database](https://msdn.microsoft.com/en-us/library/ms189272.aspx) - -#### Requirements - -* Target machine must be running Windows Server 2008 R2 or later. -* Target machine must be running SQL Server Database Engine 2008 or later. - -#### Parameters - -* **`[String]` Name** _(Key)_: The SQL database name. -* **`[String]` InstanceName** _(Key)_: The name of the SQL instance to be configured. -* **`[String]` RecoveryModel** _(Required)_: The recovery model to use for the database. - { Full | Simple | BulkLogged }. -* **`[String]` ServerName** _(Write)_: The host name of the SQL Server to be configured. - Default value is `$env:COMPUTERNAME`. - -#### Examples - -* [Set the RecoveryModel of a database](/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1) - -#### Known issues - -All issues are not listed here, see [here for all open issues](https://github.com/dsccommunity/SqlServerDsc/issues?q=is%3Aissue+is%3Aopen+in%3Atitle+SqlDatabaseRecoveryModel). - ### SqlDatabaseRole This resource is used to create a database role when Ensure is set to 'Present' diff --git a/build.yaml b/build.yaml index e291e5089..28b7c3291 100644 --- a/build.yaml +++ b/build.yaml @@ -62,6 +62,7 @@ Pester: # Deprecated resources - source/DSCResources/MSFT_SqlServerNetwork - source/DSCResources/MSFT_SqlDatabaseOwner + - source/DSCResources/MSFT_SqlDatabaseRecoveryModel Script: - tests/Unit ExcludeTag: @@ -79,11 +80,13 @@ DscTest: # Deprecated resources - source/DSCResources/MSFT_SqlServerNetwork - source/DSCResources/MSFT_SqlDatabaseOwner + - source/DSCResources/MSFT_SqlDatabaseRecoveryModel ExcludeModuleFile: - Modules/DscResource.Common # Deprecated resources - DSCResources/MSFT_SqlServerNetwork - DSCResources/MSFT_SqlDatabaseOwner + - DSCResources/MSFT_SqlDatabaseRecoveryModel Resolve-Dependency: Gallery: 'PSGallery' diff --git a/codecov.yml b/codecov.yml index 2b12e7256..e8f3830b9 100644 --- a/codecov.yml +++ b/codecov.yml @@ -31,3 +31,4 @@ fixes: ignore: - 'source/DSCResources/MSFT_SqlServerNetwork' - 'source/DSCResources/MSFT_SqlDatabaseOwner' + - 'source/DSCResources/MSFT_SqlDatabaseRecoveryModel' diff --git a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 similarity index 97% rename from source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 index c1012c661..e07f65dd9 100644 --- a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.psm1 +++ b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.psm1 @@ -1,3 +1,12 @@ +<# + DEPRECATION NOTICE: + + THIS RESOURCE IS DEPRECATED! + + Changes to this resource will no longer be merged. Instead please use the + resource SqlDatabase. +#> + $script:sqlServerDscHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\SqlServerDsc.Common' $script:resourceHelperModulePath = Join-Path -Path $PSScriptRoot -ChildPath '..\..\Modules\DscResource.Common' diff --git a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.schema.mof b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof similarity index 90% rename from source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.schema.mof rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof index eff3e3bf3..d39fa1440 100644 --- a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/DSC_SqlDatabaseRecoveryModel.schema.mof +++ b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/MSFT_SqlDatabaseRecoveryModel.schema.mof @@ -1,5 +1,5 @@ [ClassVersion("1.0"), FriendlyName("SqlDatabaseRecoveryModel")] -class DSC_SqlDatabaseRecoveryModel : OMI_BaseResource +class MSFT_SqlDatabaseRecoveryModel : OMI_BaseResource { [Key, Description("The SQL database name")] String Name; [Key, Description("The name of the SQL instance to be configured.")] String InstanceName; diff --git a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/en-US/DSC_SqlDatabaseRecoveryModel.strings.psd1 b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 similarity index 62% rename from source/DSCResources/DSC_SqlDatabaseRecoveryModel/en-US/DSC_SqlDatabaseRecoveryModel.strings.psd1 rename to source/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 index 121e5b0ac..3295ee9f8 100644 --- a/source/DSCResources/DSC_SqlDatabaseRecoveryModel/en-US/DSC_SqlDatabaseRecoveryModel.strings.psd1 +++ b/source/DSCResources/MSFT_SqlDatabaseRecoveryModel/en-US/MSFT_SqlDatabaseRecoveryModel.strings.psd1 @@ -1,8 +1,8 @@ ConvertFrom-StringData @' - GetRecoveryModel = Get the current recovery model of the database '{0}' in the instance '{1}'. + GetRecoveryModel = THIS RESOURCE IS DEPRECATED! Get the current recovery model of the database '{0}' in the instance '{1}'. CurrentRecoveryModel = The current recovery model is '{0}' for the database '{1}'. DatabaseNotFound = The database '{0}' does not exist. - SetRecoveryModel = Setting the recovery model of database '{0}'. + SetRecoveryModel = THIS RESOURCE IS DEPRECATED! Setting the recovery model of database '{0}'. ChangeRecoveryModel = The recovery model for the database '{0}' was changed to '{1}'. TestingConfiguration = Determines if the database '{0}' on the instance '{1}' has the desired recovery model. '@ diff --git a/source/Examples/README.md b/source/Examples/README.md index fb2cab44a..55ce2b82c 100644 --- a/source/Examples/README.md +++ b/source/Examples/README.md @@ -18,7 +18,6 @@ These are the links to the examples for each individual resource. - [SqlDatabase](Resources/SqlDatabase) - [SqlDatabaseDefaultLocation](Resources/SqlDatabaseDefaultLocation) - [SqlDatabasePermission](Resources/SqlDatabasePermission) -- [SqlDatabaseRecoveryModel](Resources/SqlDatabaseRecoveryModel) - [SqlDatabaseRole](Resources/SqlDatabaseRole) - [SqlDatabaseUser](Resources/SqlDatabaseUser) - [SqlRS](Resources/SqlRS) diff --git a/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 b/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 deleted file mode 100644 index e984228db..000000000 --- a/source/Examples/Resources/SqlDatabaseRecoveryModel/1-SetDatabaseRecoveryModel.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -<# - .DESCRIPTION - This example shows how to set the Recovery Model - to "Full" for SQL database "AdventureWorks". -#> - -Configuration Example -{ - param - ( - [Parameter(Mandatory = $true)] - [System.Management.Automation.PSCredential] - $SqlAdministratorCredential - ) - - Import-DscResource -ModuleName 'SqlServerDsc' - - node localhost - { - SqlDatabase 'Add_SqlDatabaseAdventureworks' - { - Ensure = 'Present' - Name = 'Adventureworks' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlDatabase 'Add_SqlDatabaseAdventureWorks2012' - { - Ensure = 'Present' - Name = 'AdventureWorks2012' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlDatabaseRecoveryModel 'Set_SqlDatabaseRecoveryModel_Adventureworks' - { - Name = 'Adventureworks' - RecoveryModel = 'Full' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - - SqlDatabaseRecoveryModel 'Set_SqlDatabaseRecoveryModel_AdventureWorks2012' - { - Name = 'AdventureWorks2012' - RecoveryModel = 'Simple' - ServerName = 'sqltest.company.local' - InstanceName = 'DSC' - - PsDscRunAsCredential = $SqlAdministratorCredential - } - } -} diff --git a/tests/Unit/DSC_SqlDatabaseRecoveryModel.Tests.ps1 b/tests/Unit/DSC_SqlDatabaseRecoveryModel.Tests.ps1 deleted file mode 100644 index 4325dd250..000000000 --- a/tests/Unit/DSC_SqlDatabaseRecoveryModel.Tests.ps1 +++ /dev/null @@ -1,275 +0,0 @@ -<# - .SYNOPSIS - Automated unit test for DSC_SqlDatabaseRecoveryModel DSC resource. - - .NOTES - To run this script locally, please make sure to first run the bootstrap - script. Read more at - https://github.com/PowerShell/SqlServerDsc/blob/dev/CONTRIBUTING.md#bootstrap-script-assert-testenvironment -#> -Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '..\TestHelpers\CommonTestHelper.psm1') - -if (-not (Test-BuildCategory -Type 'Unit')) -{ - return -} - -$script:dscModuleName = 'SqlServerDsc' -$script:dscResourceName = 'DSC_SqlDatabaseRecoveryModel' - -function Invoke-TestSetup -{ - try - { - Import-Module -Name DscResource.Test -Force -ErrorAction 'Stop' - } - catch [System.IO.FileNotFoundException] - { - throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -Tasks build" first.' - } - - $script:testEnvironment = Initialize-TestEnvironment ` - -DSCModuleName $script:dscModuleName ` - -DSCResourceName $script:dscResourceName ` - -ResourceType 'Mof' ` - -TestType 'Unit' -} - -function Invoke-TestCleanup -{ - Restore-TestEnvironment -TestEnvironment $script:testEnvironment -} - -Invoke-TestSetup - -try -{ - InModuleScope $script:dscResourceName { - $mockServerName = 'localhost' - $mockInstanceName = 'MSSQLSERVER' - $mockSqlDatabaseName = 'AdventureWorks' - $mockSqlDatabaseRecoveryModel = 'Simple' - $mockInvalidOperationForAlterMethod = $false - $mockExpectedRecoveryModel = 'Simple' - - # Default parameters that are used for the It-blocks - $mockDefaultParameters = @{ - InstanceName = $mockInstanceName - ServerName = $mockServerName - } - - #region Function mocks - $mockConnectSQL = { - return @( - ( - New-Object -TypeName Object | - Add-Member -MemberType NoteProperty -Name InstanceName -Value $mockInstanceName -PassThru | - Add-Member -MemberType NoteProperty -Name ComputerNamePhysicalNetBIOS -Value $mockServerName -PassThru | - Add-Member -MemberType ScriptProperty -Name Databases -Value { - return @{ - $mockSqlDatabaseName = ( New-Object -TypeName Object | - Add-Member -MemberType NoteProperty -Name Name -Value $mockSqlDatabaseName -PassThru | - Add-Member -MemberType NoteProperty -Name RecoveryModel -Value $mockSqlDatabaseRecoveryModel -PassThru | - Add-Member -MemberType ScriptMethod -Name Alter -Value { - if ($mockInvalidOperationForAlterMethod) - { - throw 'Mock Alter Method was called with invalid operation.' - } - - if ( $this.RecoveryModel -ne $mockExpectedRecoveryModel ) - { - throw "Called Alter Drop() method without setting the right recovery model. Expected '{0}'. But was '{1}'." ` - -f $mockExpectedRecoveryModel, $this.RecoveryModel - } - } -PassThru - ) - } - } -PassThru -Force - ) - ) - } - #endregion - - Describe "DSC_SqlDatabaseRecoveryModel\Get-TargetResource" -Tag 'Get' { - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When passing values to parameters and database does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'UnknownDatabase' - RecoveryModel = 'Full' - } - - $errorMessage = $script:localizedData.DatabaseNotFound -f $testParameters.Name - - { Get-TargetResource @testParameters } | Should -Throw $errorMessage - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should return wrong RecoveryModel' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Full' - } - - $result = Get-TargetResource @testParameters - $result.RecoveryModel | Should -Not -Be $testParameters.RecoveryModel - } - - It 'Should return the same values as passed as parameters' { - $result.ServerName | Should -Be $testParameters.ServerName - $result.InstanceName | Should -Be $testParameters.InstanceName - $result.Name | Should -Be $testParameters.Name - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is in the desired state for a database' { - It 'Should return the correct RecoveryModel' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Simple' - } - - $result = Get-TargetResource @testParameters - $result.RecoveryModel | Should -Be $testParameters.RecoveryModel - } - - It 'Should return the same values as passed as parameters' { - $result.ServerName | Should -Be $testParameters.ServerName - $result.InstanceName | Should -Be $testParameters.InstanceName - $result.Name | Should -Be $testParameters.Name - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - - Describe "DSC_SqlDatabaseRecoveryModel\Test-TargetResource" -Tag 'Test' { - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is not in the desired state' { - It 'Should return the state as false when desired recovery model is not correct' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Full' - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $false - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is in the desired state' { - It 'Should return the state as true when desired recovery model is correct' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Simple' - } - - $result = Test-TargetResource @testParameters - $result | Should -Be $true - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - - Describe "DSC_SqlDatabaseRecoveryModel\Set-TargetResource" -Tag 'Set' { - BeforeEach { - Mock -CommandName Connect-SQL -MockWith $mockConnectSQL -Verifiable - } - - Context 'When the system is not in the desired state, and database does not exist' { - It 'Should throw the correct error' { - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'UnknownDatabase' - RecoveryModel = 'Full' - } - - $errorMessage = $script:localizedData.DatabaseNotFound -f $testParameters.Name - - { Set-TargetResource @testParameters } | Should -Throw $errorMessage - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should not throw when calling the alter method when desired recovery model should be set' { - $mockExpectedRecoveryModel = 'Full' - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Full' - } - - { Set-TargetResource @testParameters } | Should -Not -Throw - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Context 'When the system is not in the desired state' { - It 'Should throw when calling the alter method when desired recovery model should be set' { - $mockInvalidOperationForAlterMethod = $true - $mockExpectedRecoveryModel = 'Full' - $testParameters = $mockDefaultParameters - $testParameters += @{ - Name = 'AdventureWorks' - RecoveryModel = 'Full' - } - - $throwInvalidOperation = ('Exception calling "Alter" with "0" argument(s): ' + - '"Mock Alter Method was called with invalid operation."') - - { Set-TargetResource @testParameters } | Should -Throw $throwInvalidOperation - } - - It 'Should call the mock function Connect-SQL' { - Assert-MockCalled -CommandName Connect-SQL -Exactly -Times 1 -Scope Context - } - } - - Assert-VerifiableMock - } - } -} -finally -{ - Invoke-TestCleanup -}