| description | applyTo |
|---|---|
SqlServerDsc-specific guidelines for AI development. |
** |
- Public commands:
{Verb}-SqlDsc{Noun}format - Private function:
{Verb}-{Noun}format
- Database Engine resources: inherit
SqlResourceBase- Inheriting
SqlResourceBase; addInstanceName,ServerName, andCredentialto$this.ExcludeDscProperties SqlResourceBaseprovides:InstanceName,ServerName,Credential,Reasons,GetServerObject()
- Inheriting
- Always prefer SMO over T-SQL
- Unit tests: Use SMO stub types from SMO.cs, never mock SMO types
- Run tests in new session after changing SMO.cs
- Database Engine: instance
DSCSQLTEST - Reporting Services: instance
SSRS - Power BI Report Server: instance
PBIRS
- Unit tests: Add
$env:SqlServerDscCI = $trueinBeforeAll, remove inAfterAll - Integration tests:
- If requiring SQL Server DB, start the Windows service in
BeforeAll, stop it inAfterAll. - Use
Connect-SqlDscDatabaseEnginefor SQL Server DB session, and always with correct CI credentials - Use
Disconnect-SqlDscDatabaseEngineafterConnect-SqlDscDatabaseEngine - Test config: tests/Integration/Commands/README.md and tests/Integration/Resources/README.md
- Integration test script files must be added to a group within the test stage in ./azure-pipelines.yml.
- Choose the appropriate group number based on the required dependencies
- If requiring SQL Server DB, start the Windows service in
- When unit test tests classes or commands that contain SMO types, e.g.
[Microsoft.SqlServer.Management.Smo.*]- Ensure they are properly stubbed in SMO.cs
- Load SMO stub types from SMO.cs in unit test files, e.g.
Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs" - After changing SMO stub types, run tests in a new PowerShell session for changes to take effect.