Skip to content

Conversation

@johlju
Copy link
Member

@johlju johlju commented Sep 9, 2025

Pull Request (PR) description

  • Test-SqlDscAgentAlertProperty
    • New command to test specific properties of SQL Agent alerts.
    • Supports testing severity and message ID properties.
    • Requires at least one property parameter to be specified.
    • Supports pipeline input of
      [Microsoft.SqlServer.Management.Smo.Agent.Alert] objects.
  • New-SqlDscAgentAlert
    • Updated the command to use Test-SqlDscIsAgentAlert instead of directly
      calling Get-AgentAlertObject when checking if an alert already exists
      (issue #2202).
  • Test-SqlDscIsAgentAlert
    • Removed optional Severity and MessageId parameters - use
      Test-SqlDscAgentAlertProperty instead for property testing.
    • Now only tests for alert existence.
    • Added support for pipeline input of
      [Microsoft.SqlServer.Management.Smo.Agent.Alert] objects.
    • Updated examples and documentation to reflect the simplified functionality.

This Pull Request (PR) fixes the following issues

Task list

  • Added an entry to the change log under the Unreleased section of the
    file CHANGELOG.md. Entry should say what was changed and how that
    affects users (if applicable), and reference the issue being resolved
    (if applicable).
  • Resource documentation updated in the resource's README.md.
  • Resource parameter descriptions updated in schema.mof.
  • Comment-based help updated, including parameter descriptions.
  • Localization strings updated.
  • Examples updated.
  • Unit tests updated. See DSC Community Testing Guidelines.
  • Integration tests updated (where possible). See DSC Community Testing Guidelines.
  • Code changes adheres to DSC Community Style Guidelines.

This change is Reviewable

… existing changes and prohibiting duplicates in the Unreleased section
…or Write-Error and emphasizing return usage to prevent further processing.
…emove unnecessary severity and message ID checks
@johlju johlju requested a review from a team as a code owner September 9, 2025 10:57
@coderabbitai
Copy link

coderabbitai bot commented Sep 9, 2025

Walkthrough

Splits Test-SqlDscAgentAlert into an existence-only cmdlet (Test-SqlDscIsAgentAlert) and a property-testing cmdlet (Test-SqlDscAgentAlertProperty); updates New-SqlDscAgentAlert to use the existence check; adds/updates unit and integration tests, localization strings, CI/pipeline entries, contributor guidelines, and adds a module dependency.

Changes

Cohort / File(s) Summary
Public cmdlets: SQL Agent alerts
source/Public/Test-SqlDscIsAgentAlert.ps1, source/Public/Test-SqlDscAgentAlertProperty.ps1, source/Public/New-SqlDscAgentAlert.ps1
Adds Test-SqlDscIsAgentAlert (existence boolean, alias Test-SqlDscAgentAlert); introduces Test-SqlDscAgentAlertProperty (property-based checks with new parameter sets and pipeline AlertObject); updates New-SqlDscAgentAlert to call the existence check.
Localization strings
source/en-US/SqlServerDsc.strings.psd1
Removes old Test_SqlDscAgentAlert block; adds Test-SqlDscIsAgentAlert (3 keys) and Test-SqlDscAgentAlertProperty (1 key); updates message IDs and message-grouping.
Integration tests & manifest / CI
tests/Integration/Commands/Test-SqlDscIsAgentAlert.Integration.Tests.ps1, tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1, tests/Integration/Commands/README.md, azure-pipelines.yml
Adds two integration suites (existence and property); updates README manifest and pipeline to run both tests instead of the single previous suite.
Unit tests: new/updated suites
tests/Unit/Public/Test-SqlDscIsAgentAlert.Tests.ps1, tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1, tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1, tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
Adds unit tests for existence cmdlet; rewrites tests for property cmdlet and updates New-SqlDscAgentAlert unit tests to mock/verify the new existence cmdlet; introduces CI env var setup/teardown in tests.
Unit tests: suppression and stubs cleanup
tests/Unit/Classes/SqlAgentAlert.Tests.ps1, tests/Unit/Private/Get-AgentAlertObject.Tests.ps1, tests/Unit/Public/Deny-SqlDscServerPermission.Tests.ps1, tests/Unit/Public/Get-SqlDscAgentAlert.Tests.ps1, tests/Unit/Public/Remove-SqlDscAgentAlert.Tests.ps1, tests/Unit/Stubs/SMO.cs
Normalizes SuppressMessageAttribute usage to include Justification, removes redundant suppression lines, and updates comment filename references; no behavioral changes.
Integration tests: property suite
tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1
New integration suite validating property-based checks (Severity/MessageId), error cases, test alert creation/cleanup across SQL versions.
CHANGELOG
CHANGELOG.md
Documents public API rename Test-SqlDscAgentAlertTest-SqlDscIsAgentAlert, addition of Test-SqlDscAgentAlertProperty, and update to New-SqlDscAgentAlert existence-check behavior.
Contributor instructions & style guides
.github/instructions/SqlServerDsc-guidelines.instructions.md, .github/instructions/dsc-community-style-guidelines.instructions.md, .github/instructions/dsc-community-style-guidelines-changelog.instructions.md, .github/instructions/dsc-community-style-guidelines-powershell.instructions.md, .github/copilot-instructions.md
Rephrases headings and adds Build & Test Workflow Requirements (pwsh, run scripts from repo root, ./build.ps1 -Tasks noop/build, Invoke-Pester usage), clarifies changelog duplicate rules, and updates PowerShell style guidance (alias attribute, INPUTS/OUTPUTS repetition, Write-Error requirements).
Module requirements
RequiredModules.psd1
Adds dependency 'Viscalyx.Common' = 'latest'.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant PS as PowerShell
  participant New as New-SqlDscAgentAlert
  participant TestExist as Test-SqlDscIsAgentAlert
  participant SMO as Get-AgentAlertObject (SMO)

  User->>PS: Invoke New-SqlDscAgentAlert -ServerObject -Name
  PS->>New: call
  New->>TestExist: Test-SqlDscIsAgentAlert -ServerObject -Name
  TestExist->>SMO: Get-AgentAlertObject -ServerObject -Name
  alt Alert exists
    SMO-->>TestExist: Alert object
    TestExist-->>New: true
    New-->>PS: treat as exists (no create)
  else Not found
    SMO-->>TestExist: null
    TestExist-->>New: false
    New-->>PS: proceed to create alert
  end
Loading
sequenceDiagram
  autonumber
  actor User
  participant PS as PowerShell
  participant Prop as Test-SqlDscAgentAlertProperty
  participant SMO as Get-AgentAlertObject (optional)

  rect rgba(230,240,255,0.5)
  note right of Prop: ByServerAndName parameter set
  User->>PS: Test-SqlDscAgentAlertProperty -ServerObject -Name -Severity|-MessageId
  PS->>Prop: call
  Prop->>SMO: Get-AgentAlertObject (ByServerAndName)
  Prop-->>PS: true/false (property match)
  end

  rect rgba(230,255,230,0.5)
  note right of Prop: ByAlertObject parameter set (pipeline)
  User->>PS: Get-SqlDscAgentAlert ... | Test-SqlDscAgentAlertProperty -Severity|-MessageId
  PS->>Prop: pipeline AlertObject
  Prop-->>PS: true/false (property match)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Pre-merge checks

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The PR implements the core rename: Test-SqlDscIsAgentAlert was added and includes an alias Test-SqlDscAgentAlert, documentation/examples/tests and the CHANGELOG were updated, and a separate Test-SqlDscAgentAlertProperty was introduced for property checks, which satisfies most linked-issue objectives. However, the linked issue explicitly requested treating the rename as a breaking change with deprecation notices and migration guidance, and I do not see explicit deprecation/migration guidance in the PR description or summaries. Because that stated requirement is missing, the linked-issue compliance is incomplete. Add explicit deprecation/migration guidance: include deprecation text in comment-based help and CHANGELOG with a recommended migration path and timeline, document the alias behavior in the README/examples, and optionally add (or document plans for) a runtime deprecation warning when the old name is used so users have a clear upgrade path.
Out of Scope Changes Check ⚠️ Warning Several modifications appear unrelated to the linked-issue objective of a command rename: notably the addition of a new dependency 'Viscalyx.Common' in RequiredModules.psd1 and multiple .github instruction/style guideline changes across the repo; those items are not justified by the rename and complicate review. Test and pipeline updates that reference the new/renamed tests are in scope, but the dependency and broad guidance/doc changes should be justified or split out. Either remove or clearly justify the 'Viscalyx.Common' dependency and move unrelated .github guideline/instructions edits into a separate PR; if the dependency is required for the new cmdlets/tests, state that in the PR description and show minimal usage so reviewers can validate it.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Test-SqlDscIsAgentAlert: Command rename proposal" is concise, directly reflects the primary rename implemented in the changeset, and avoids noisy details; it clearly signals the main intent for reviewers scanning history. It is specific to the change and readable. No change is required.
Description Check ✅ Passed The PR description accurately summarizes the functional changes (new Test-SqlDscAgentAlertProperty, rename to Test-SqlDscIsAgentAlert, New-SqlDscAgentAlert update), references the linked issue (#2202), and lists the checklist status, so it is on-topic and sufficiently related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
source/Public/New-SqlDscAgentAlert.ps1 (1)

89-91: Enforce “either Severity or MessageId is required.”

Assert-BoundParameter here only enforces mutual exclusivity; it doesn’t ensure at least one is provided. Without either, .Create() is invoked with neither property set, likely failing later. Add an early, localized parameter validation.

         # Validate that both Severity and MessageId are not specified
         Assert-BoundParameter -BoundParameterList $PSBoundParameters -MutuallyExclusiveList1 @('Severity') -MutuallyExclusiveList2 @('MessageId')
 
+        # Require at least one of Severity or MessageId
+        if (-not ($PSBoundParameters.ContainsKey('Severity') -or $PSBoundParameters.ContainsKey('MessageId')))
+        {
+            $errorMessage = $script:localizedData.New_SqlDscAgentAlert_SeverityOrMessageIdRequired
+            New-ArgumentException -Message $errorMessage -ArgumentName 'Severity,MessageId'
+        }

Follow-up:

  • Add New_SqlDscAgentAlert_SeverityOrMessageIdRequired to source/en-US/SqlServerDsc.strings.psd1.
tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (1)

127-137: Add negative-path tests for parameter validation.

Cover:

  • Both Severity and MessageId passed (mutually exclusive).
  • Neither passed (now required by code fix).
 AfterAll {
@@
 Describe 'New-SqlDscAgentAlert' -Tag 'Public' {
+    Context 'When invalid parameter combinations are used' {
+        BeforeAll {
+            $script:mockServerObject = [Microsoft.SqlServer.Management.Smo.Server]::CreateTypeInstance()
+            $script:mockServerObject.JobServer = [Microsoft.SqlServer.Management.Smo.Agent.JobServer]::CreateTypeInstance()
+            Mock -CommandName 'Test-SqlDscIsAgentAlert' -MockWith { return $false }
+        }
+
+        It 'Should throw when both Severity and MessageId are specified' {
+            { New-SqlDscAgentAlert -ServerObject $script:mockServerObject -Name 'X' -Severity 16 -MessageId 50001 } |
+                Should -Throw
+        }
+
+        It 'Should throw when neither Severity nor MessageId is specified' {
+            { New-SqlDscAgentAlert -ServerObject $script:mockServerObject -Name 'X' } |
+                Should -Throw
+        }
+    }

Also applies to: 143-144, 173-174, 186-187, 210-212, 236-237

tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (4)

26-36: Missing $env:SqlServerDscCI setup in BeforeAll

According to the guidelines, unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll.

Add this environment variable setup:

 BeforeAll {
     $script:dscModuleName = 'SqlServerDsc'
 
+    # Setting up SqlServerDscCI variable
+    $env:SqlServerDscCI = $true
+
     Import-Module -Name $script:dscModuleName -Force -ErrorAction 'Stop'

38-44: Missing cleanup of $env:SqlServerDscCI in AfterAll

The $env:SqlServerDscCI variable should be removed in the AfterAll block.

Add the cleanup:

 AfterAll {
     $PSDefaultParameterValues.Remove('Mock:ModuleName')
     $PSDefaultParameterValues.Remove('Should:ModuleName')
 
+    # Remove SqlServerDscCI variable
+    Remove-Item -Path 'env:SqlServerDscCI' -ErrorAction 'SilentlyContinue'
+
     # Unload the module being tested so that it doesn't impact any other tests.
     Get-Module -Name $script:dscModuleName -All | Remove-Module -Force
 }

36-36: Missing InModuleScope in PSDefaultParameterValues

According to the guidelines and retrieved learnings, public command tests should include $PSDefaultParameterValues['InModuleScope:ModuleName'] to support accessing localized strings when necessary.

Add the missing parameter:

     $PSDefaultParameterValues['Mock:ModuleName'] = $script:dscModuleName
     $PSDefaultParameterValues['Should:ModuleName'] = $script:dscModuleName
+    $PSDefaultParameterValues['InModuleScope:ModuleName'] = $script:dscModuleName

39-40: Missing cleanup of InModuleScope in AfterAll

Since we're adding InModuleScope:ModuleName to PSDefaultParameterValues, it should also be removed in AfterAll.

Add the cleanup:

 AfterAll {
     $PSDefaultParameterValues.Remove('Mock:ModuleName')
     $PSDefaultParameterValues.Remove('Should:ModuleName')
+    $PSDefaultParameterValues.Remove('InModuleScope:ModuleName')
🧹 Nitpick comments (17)
.github/instructions/dsc-community-style-guidelines.instructions.md (1)

13-16: Add a blank line between heading and list to satisfy MD032.

Prevents markdownlint “blanks-around-lists” on Line 14.

 ## Build & Test Workflow
+- 
 - Run scripts in `pwsh`; always from repository root
 - Build before running tests: `.\build.ps1 -Tasks build`
 - Always run tests in new PowerShell session: `Invoke-Pester -Path @({test paths}) -Output Detailed`
tests/Unit/Stubs/SMO.cs (1)

1541-1541: Restore trailing newline at EOF (POSIX convention).

Minor consistency/readability nit.

Also applies to: 1639-1639

RequiredModules.psd1 (1)

69-72: Consider pinning Viscalyx.Common to a version range.

Using 'latest' can cause non‑deterministic CI. If feasible, pin to a stable range (e.g., a specific major) and bump intentionally.

-    'Viscalyx.Common'              = 'latest' # Invoke-PesterJob to run tests
+    'Viscalyx.Common'              = '1.*'    # Invoke-PesterJob to run tests; pin major for reproducibility
tests/Integration/Commands/README.md (1)

66-67: Also list Test-SqlDscAgentAlertProperty in the run‑order table (if it has an integration test).

Keeps docs aligned with added integration test file mentioned in the PR.

 Set-SqlDscAgentAlert | 2 | 1 (Install-SqlDscServer), 0 (Prerequisites) | DSCSQLTEST | -
-Test-SqlDscIsAgentAlert | 2 | 1 (Install-SqlDscServer), 0 (Prerequisites) | DSCSQLTEST | -
+Test-SqlDscIsAgentAlert | 2 | 1 (Install-SqlDscServer), 0 (Prerequisites) | DSCSQLTEST | -
+Test-SqlDscAgentAlertProperty | 2 | 1 (Install-SqlDscServer), 0 (Prerequisites) | DSCSQLTEST | -
 Remove-SqlDscAgentAlert | 8 | 2 (New-SqlDscAgentAlert) | DSCSQLTEST | -
.github/instructions/SqlServerDsc-guidelines.instructions.md (2)

8-15: Add blank line after heading and wrap long command lines (MD022/MD032/MD013).

Insert a blank line after the “Build & Test Workflow Requirements” heading, and wrap long bullets by moving commands into fenced blocks.

-## Build & Test Workflow Requirements
-- Run in `pwsh`
+## Build & Test Workflow Requirements
+
+- Run in `pwsh`
 - Run scripts from project root
-- Setup build environment (once per `pwsh` session): `.build.ps1 -Task noop`
-- Build project: `.build.ps1 -Task build`
-- Run tests without coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
-- Run QA tests: `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
+- Setup build environment (once per `pwsh` session):
+  
+  ```powershell
+  .build.ps1 -Task noop
+  ```
+
+- Build project:
+  
+  ```powershell
+  .build.ps1 -Task build
+  ```
+
+- Run tests without coverage (wildcards allowed):
+  
+  ```powershell
+  Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage
+  ```
+
+- Run QA tests:
+  
+  ```powershell
+  Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage
+  ```
 - Never run integration tests locally

37-46: Add blank line after “Tests Requirements” heading (MD022).

Minor formatting fix.

-## Tests Requirements
+## Tests Requirements
+
 - Unit tests: Add `$env:SqlServerDscCI = $true` in `BeforeAll`, remove in `AfterAll`
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (1)

95-98: Wrap long “Write-Error” guidance lines to satisfy MD013.

Reflow into shorter lines; no content change.

-- Use `Write-Error` for non-terminating errors
-  - Always include `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID matching localized string ID), `-TargetObject` (object causing error)
-  - Always use `return` after `Write-Error` to avoid further processing
+- Use `Write-Error` for non-terminating errors
+  - Always include `-Message` (localized), `-Category` (relevant category),
+    `-ErrorId` (unique ID matching the localized string ID),
+    `-TargetObject` (the object causing the error)
+  - Always use `return` after `Write-Error` to avoid further processing
CHANGELOG.md (2)

94-100: Tighten formatting per changelog style (wrap >80 chars; ≤2 bullet points).

  • Wrap long lines at word boundaries.
  • Condense the 4 sub-bullets to ≤2 concise items (guideline: max 2 per change type).

162-173: Add migration guidance for the rename (alias/deprecation).

Under Test-SqlDscIsAgentAlert, add a short sentence noting the old name, the [Alias()] for compatibility, and that the old name will be removed in a future major release, referencing [issue #2202].

tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (1)

26-36: Set/unset CI marker env var in unit tests.

Per guidelines, set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll.

 BeforeAll {
+    $env:SqlServerDscCI = $true
     $script:dscModuleName = 'SqlServerDsc'
@@
 AfterAll {
+    Remove-Item Env:\SqlServerDscCI -ErrorAction SilentlyContinue
tests/Unit/Public/Test-SqlDscIsAgentAlert.Tests.ps1 (1)

46-63: Make parameter set assertions less brittle.

Comparing ParameterSet.ToString() is version-sensitive. Prefer asserting the count, names, and parameter metadata directly (which you already partly do). Consider dropping the ToString() equality and asserting on Names and Mandatory/ValueFromPipeline flags only.

source/Public/Test-SqlDscIsAgentAlert.ps1 (2)

56-58: Fix localized “testing” message to match existence-only behavior.

The message references “desired properties” but this cmdlet tests existence only. Update the en-US string to avoid confusion. See suggested change in SqlServerDsc.strings.psd1.


39-51: Clarify PR note about pipeline input of [Alert] for this cmdlet.

The implementation only accepts [Server] via pipeline, not [Microsoft.SqlServer.Management.Smo.Agent.Alert]. If [Alert] pipeline support was intended, add a ByAlertObject parameter set; otherwise, update PR/docs to avoid confusion.

Happy to propose a ByAlertObject parameter set if you want to support [Alert] pipeline input here as well.

source/en-US/SqlServerDsc.strings.psd1 (1)

437-441: Adjust Test-SqlDscIsAgentAlert testing string to reflect existence-only.

Current text implies property checks. Suggest:

-    Test_SqlDscIsAgentAlert_TestingAlert = Testing if the SQL Agent Alert '{0}' exists and has the desired properties. (TSIAA0001)
+    Test_SqlDscIsAgentAlert_TestingAlert = Testing if the SQL Agent Alert '{0}' exists. (TSIAA0001)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (1)

27-36: Merge duplicate .INPUTS sections.

Keep a single .INPUTS section listing each accepted pipeline type to match help guidelines.

-    .INPUTS
-        Microsoft.SqlServer.Management.Smo.Server
-
-        SQL Server Database Engine instance object.
-
-    .INPUTS
-        Microsoft.SqlServer.Management.Smo.Agent.Alert
-
-        SQL Agent Alert object.
+    .INPUTS
+        Microsoft.SqlServer.Management.Smo.Server
+        SQL Server Database Engine instance object.
+
+        Microsoft.SqlServer.Management.Smo.Agent.Alert
+        SQL Agent Alert object.
tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (2)

136-140: Inefficient mocking for parameter validation test

The test is mocking Get-AgentAlertObject unnecessarily since the error is thrown by Assert-BoundParameter before that command would be called.

Remove the unnecessary mock:

             Mock -CommandName 'Assert-BoundParameter' -ModuleName $script:dscModuleName -MockWith { throw 'At least one parameter required' }
-            Mock -CommandName 'Get-AgentAlertObject' -ModuleName $script:dscModuleName
         }

211-234: Improve Write-Error verification test structure

The test at Line 227-234 duplicates the functionality call with overlapping verification concerns. Consider consolidating or clarifying the test intent.

Consider restructuring to avoid duplication:

-        It 'Should return false when alert does not exist (with Severity)' {
-            $result = Test-SqlDscAgentAlertProperty -ServerObject $script:mockServerObject -Name 'NonExistentAlert' -Severity 16
-
-            $result | Should -BeFalse
-            Should -Invoke -CommandName 'Get-AgentAlertObject' -ModuleName $script:dscModuleName -Times 1 -Exactly
-            Should -Invoke -CommandName 'Write-Error' -ModuleName $script:dscModuleName -Times 1 -Exactly
-        }
-
-        It 'Should return false when alert does not exist (with MessageId)' {
-            $result = Test-SqlDscAgentAlertProperty -ServerObject $script:mockServerObject -Name 'NonExistentAlert' -MessageId 50001
-
-            $result | Should -BeFalse
-            Should -Invoke -CommandName 'Get-AgentAlertObject' -ModuleName $script:dscModuleName -Times 1 -Exactly
-            Should -Invoke -CommandName 'Write-Error' -ModuleName $script:dscModuleName -Times 1 -Exactly
-        }
-
-        It 'Should call Write-Error with correct parameters when alert does not exist' {
+        It 'Should return false and call Write-Error when alert does not exist (with Severity)' {
             $result = Test-SqlDscAgentAlertProperty -ServerObject $script:mockServerObject -Name 'NonExistentAlert' -Severity 16
 
             $result | Should -BeFalse
+            Should -Invoke -CommandName 'Get-AgentAlertObject' -ModuleName $script:dscModuleName -Times 1 -Exactly
             Should -Invoke -CommandName 'Write-Error' -ModuleName $script:dscModuleName -ParameterFilter {
                 $Category -eq 'ObjectNotFound' -and $ErrorId -eq 'TSAAP0002' -and $TargetObject -eq 'NonExistentAlert'
             } -Times 1 -Exactly
         }
+
+        It 'Should return false and call Write-Error when alert does not exist (with MessageId)' {
+            $result = Test-SqlDscAgentAlertProperty -ServerObject $script:mockServerObject -Name 'NonExistentAlert' -MessageId 50001
+
+            $result | Should -BeFalse
+            Should -Invoke -CommandName 'Get-AgentAlertObject' -ModuleName $script:dscModuleName -Times 1 -Exactly
+            Should -Invoke -CommandName 'Write-Error' -ModuleName $script:dscModuleName -Times 1 -Exactly
+        }

@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94%. Comparing base (1440fce) to head (e9d788c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@         Coverage Diff          @@
##           main   #2204   +/-   ##
====================================
  Coverage    94%     94%           
====================================
  Files       148     149    +1     
  Lines      9162    9163    +1     
====================================
+ Hits       8686    8687    +1     
  Misses      476     476           
Flag Coverage Δ
unit 94% <100%> (+<1%) ⬆️
Files with missing lines Coverage Δ
source/Public/New-SqlDscAgentAlert.ps1 92% <100%> (ø)
source/Public/Test-SqlDscAgentAlertProperty.ps1 100% <100%> (ø)
source/Public/Test-SqlDscIsAgentAlert.ps1 100% <100%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (1)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (1)

107-114: Return false without emitting an error when alert is missing.

Property test should be boolean-only; emitting Write-Error makes absence an error condition and can break callers/tests.

-            if ($null -eq $alertObject)
-            {
-                $errorMessage = $script:localizedData.Test_SqlDscAgentAlertProperty_AlertNotFound -f $Name
-
-                Write-Error -Message $errorMessage -Category 'ObjectNotFound' -ErrorId 'TSAAP0002' -TargetObject $Name
-
-                return $false
-            }
+            if ($null -eq $alertObject)
+            {
+                Write-Verbose -Message ($script:localizedData.Test_SqlDscAgentAlertProperty_AlertNotFound -f $Name)
+                return $false
+            }
🧹 Nitpick comments (1)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (1)

32-36: Consolidate duplicate .INPUTS sections.

Use a single .INPUTS header listing both pipeline-accepted types (one per line) per guideline.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69ec72d and 98cba99.

📒 Files selected for processing (9)
  • .github/instructions/SqlServerDsc-guidelines.instructions.md (2 hunks)
  • azure-pipelines.yml (1 hunks)
  • source/Public/Test-SqlDscAgentAlertProperty.ps1 (3 hunks)
  • source/en-US/SqlServerDsc.strings.psd1 (1 hunks)
  • tests/Integration/Commands/README.md (1 hunks)
  • tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1 (1 hunks)
  • tests/Integration/Commands/Test-SqlDscIsAgentAlert.Integration.Tests.ps1 (2 hunks)
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (8 hunks)
  • tests/Unit/Public/Test-SqlDscIsAgentAlert.Tests.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/Unit/Public/Test-SqlDscIsAgentAlert.Tests.ps1
  • tests/Integration/Commands/Test-SqlDscIsAgentAlert.Integration.Tests.ps1
  • azure-pipelines.yml
  • tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (18)
**/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow Markdown formatting requirements for documentation

**/*.md: Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
Use 2 spaces for indentation in Markdown documents
Use '1.' for all items in ordered lists (1/1/1 numbering style)
Disable MD013 for tables/code blocks exceeding 80 characters via an inline comment
Require empty lines before and after code blocks and headings (except before line 1)
Escape backslashes in file paths only, not inside code blocks
All fenced code blocks must specify a language identifier
Format parameter names as bold
Format values/literals as inline code
Format resource/module/product names as italic
Format commands, file names, and paths as inline code

Files:

  • tests/Integration/Commands/README.md

⚙️ CodeRabbit configuration file

**/*.md: # Markdown Style Guidelines

  • Wrap lines at word boundaries when over 80 characters (except tables/code blocks)
  • Use 2 spaces for indentation
  • Use '1.' for all items in ordered lists (1/1/1 numbering style)
  • Disable MD013 rule by adding a comment for tables/code blocks exceeding 80 characters
  • Empty lines required before/after code blocks and headings (except before line 1)
  • Escape backslashes in file paths only (not in code blocks)
  • Code blocks must specify language identifiers

Text Formatting

  • Parameters: bold
  • Values/literals: inline code
  • Resource/module/product names: italic
  • Commands/files/paths: inline code

Files:

  • tests/Integration/Commands/README.md
tests/Integration/{Commands,Resources}/README.md

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

Follow integration test configuration guidance documented in tests/Integration/Commands/README.md and tests/Integration/Resources/README.md

Files:

  • tests/Integration/Commands/README.md
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow

  • Run scripts in pwsh; always from repository root
  • Build before running tests: .\build.ps1 -Tasks build
  • Always run tests in new PowerShell session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • tests/Integration/Commands/README.md
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow PowerShell code style guidelines in all PowerShell scripts, modules, and manifests

**/*.{ps1,psm1,psd1}: End files with exactly one trailing blank line
Use CRLF line endings
Allow at most two consecutive newlines in files
Use UTF-8 encoding without BOM for all files

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow test patterns strictly for maintainability in Pester tests

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.{ps1,psm1}

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.{ps1,psm1}: Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}
Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)
Always prefer SMO over T-SQL for SQL Server interaction

**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names: PascalCase with Verb-Noun format using approved verbs
Parameter names: PascalCase
Variable names: camelCase
Keywords must be lower-case
Class names: PascalCase
Include scope prefix for script/global/environment variables: $script:, $global:, $env:
Use 4 spaces for indentation (no tabs)
Use one space around operators (e.g., $a = 1 + 2)
Use one space between type and variable (e.g., [String] $name)
Use one space between keyword and parenthesis (e.g., if ($condition))
No spaces on empty lines
Try to limit lines to 120 characters
Place opening brace on a new line (except in variable assignments)
Add one newline after an opening brace
Add two newlines after a closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed
Arrays: single-line as @('one','two'), multi-line with one element per line and proper indentation
Do not use unary comma in return statements to force an array
Hashtables: empty as @{}; otherwise each property on its own line with proper indentation; property names in PascalCase
Comments: use '# Comment' (capitalized) on its own line for single-line comments
Multi-line comments use <# #> with opening/closing on their own lines; indent comment text
Do not commit commented-out code
Always add comment-based help to all functions and scripts
Comment-based help must include: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords indented 4 spaces; text indented 8 spaces
Include examples for all parameter sets and combinations in comment-based help
In comment-based help, INPUTS: list each pipeline-accepted type (o...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
tests/Unit/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

tests/Unit/**/*.ps1: In unit tests, use SMO stub types from SMO.cs and never mock real SMO types
Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll
Load SMO stub types in unit tests, e.g., Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/@(Classes|Public|Private)/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Place unit tests in tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.{ps1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Localize all strings using string keys and remove any orphaned string keys

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
tests/Unit/**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Add unit tests for all commands, functions, and resources

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.[Tt]ests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

**/*.[Tt]ests.ps1: Use Pester v5 syntax only
Test code only inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
The tested entity must be called from within It blocks
Keep results and assertions in the same It block
Avoid try-catch-finally for cleanup; use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles in tests
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should' and must not contain 'when'
Prefix mock variables with 'mock'
Each class method should have a separate Context block
Each scenario should have a separate Context block
Use nested Context blocks for complex scenarios
Do mocking in BeforeAll (use BeforeEach only when required)
Place setup/teardown hooks (BeforeAll, BeforeEach, AfterAll, AfterEach) close to usage
Use PascalCase for Pester keywords: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Prefer Should -BeTrue / -BeFalse over -Be $true / -Be $false
Never use Assert-MockCalled; use Should -Invoke instead
Do not use Should -Not -Throw; invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside an InModuleScope block
Define variables for -ForEach in a separate BeforeDiscovery close to usage
Use -ForEach only on Context and It blocks
Keep variable scope close to the usage context
Use BeforeEach and AfterEach sparingly
Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core Requirements

  • All public commands, private functions and classes must have unit tests
  • All public commands and class-based resources must have integration tests
  • Use Pester v5 syntax only
  • Test code only inside Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions start with 'Should', must not contain 'when'
  • Mock variables prefix: 'mock'

Structure & Scope

  • Public commands: Never use InModuleScope (unless retrieving localized strings)
  • Private functions/class resources: Always use InModuleScope
  • Each class method = separate Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Prefer -BeTrue/-BeFalse over -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModule...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/Public/**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

For public commands, never use InModuleScope (except for retrieving localized strings)

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/Public/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

Place public command unit tests at tests/Unit/Public/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.ps?(m|d)1

⚙️ CodeRabbit configuration file

**/*.ps?(m|d)1: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description.
  • OUTPUTS: Lis...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
source/en-US/*.strings.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)

source/en-US/*.strings.psd1: Store command/function localization in source/en-US/{MyModuleName}.strings.psd1
Store class localization in source/en-US/{ResourceClassName}.strings.psd1
Name localization keys as Verb_FunctionName_Action using underscores (e.g., Get_Database_ConnectingToDatabase)
Define strings using ConvertFrom-StringData with entries like KeyName = Message with {0} placeholder. (PREFIX0001)
Include string IDs in the form (PREFIX####), where PREFIX is initials from the class/function name and numbers are sequential from 0001

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**/*.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

In module manifests, do not use NestedModules for shared commands without specifying RootModule

Files:

  • source/en-US/SqlServerDsc.strings.psd1
source/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)

source/**/*.ps1: Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning, and $PSCmdlet.ThrowTerminatingError() messages
Use localized string keys instead of hardcoded strings in script output/messages
Assume and use $script:localizedData for accessing localized strings
When emitting messages, reference $script:localizedData.KeyName and format with the -f operator (e.g., Write-Verbose -Message ($script:localizedData.KeyName -f $value1))

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1

⚙️ CodeRabbit configuration file

source/**/*.ps1: # Localization Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String Format

ConvertFrom-StringData @'
    KeyName = Message with {0} placeholder. (PREFIX0001)
'@

String IDs

  • Format: (PREFIX####)
  • PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
  • Number: Sequential from 0001

Usage

Write-Verbose -Message ($script:localizedData.KeyName -f $value1)

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
source/Public/*.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

source/Public/*.ps1: Place public commands in source/Public/{CommandName}.ps1
Separate reusable logic into private functions (keep public commands thin)

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
🧠 Learnings (42)
📚 Learning: 2025-08-29T17:25:09.959Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:25:09.959Z
Learning: Applies to tests/Integration/**/*.Integration.Tests.ps1 : Add integration tests for all public commands and resources

Applied to files:

  • tests/Integration/Commands/README.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/[cC]ommands/*.[iI]ntegration.[tT]ests.ps1 : Place command integration tests at tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Applied to files:

  • tests/Integration/Commands/README.md
📚 Learning: 2025-08-29T17:25:09.959Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:25:09.959Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Place command integration tests in tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Applied to files:

  • tests/Integration/Commands/README.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests

Applied to files:

  • tests/Integration/Commands/README.md
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : In unit tests, use SMO stub types from SMO.cs and never mock real SMO types

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Stubs/SMO.cs : After changing SMO.cs (SMO stubs), run tests in a new PowerShell session

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Do mocking in BeforeAll (use BeforeEach only when required)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.759Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.759Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters to avoid prompts

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Keep variable scope close to the usage context

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Assign function results to variables rather than inline calls

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define variables for -ForEach in a separate BeforeDiscovery close to usage

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*.Tests.ps1 : Follow test patterns strictly for maintainability in Pester tests

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:24:39.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:24:39.268Z
Learning: Applies to tests/[u]Unit/**/*.[Tt]ests.ps1 : For commands with multiple parameter sets, use the same validation template with multiple hashtables in -ForEach

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside It blocks, assign unused return objects to $null (unless part of pipeline)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use BeforeEach and AfterEach sparingly

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Load SMO stub types in unit tests, e.g., Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Always prefer SMO over T-SQL for SQL Server interaction

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : In integration tests requiring a SQL Server DB, use Connect-SqlDscDatabaseEngine with correct CI credentials to open the session

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Avoid global variables (exception: $global:DSCMachineStatus)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required setup block at the top of each integration test: the SuppressMessage param(), a BeforeDiscovery block that ensures DscResource.Test is available (or runs build.ps1 -Tasks 'noop' and imports it), and a BeforeAll block that sets $script:moduleName and imports the module under test with -Force -ErrorAction Stop

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Follow SqlServerDsc project-specific guidelines

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit -MockWith when returning $null

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never add an empty -MockWith block

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Mock inside an InModuleScope block

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Prefix mock variables with 'mock'

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions in Pester

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-17T10:13:30.079Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2136
File: source/Public/Remove-SqlDscLogin.ps1:104-108
Timestamp: 2025-08-17T10:13:30.079Z
Learning: In SqlServerDsc unit tests, SMO object stubs (like Login objects) should have properly mocked Parent properties with correct Server stub types and valid InstanceName values, rather than handling null Parent scenarios in production code.

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: SqlServerDsc-specific guidelines override general project guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*Integration.Tests.ps1 : Always add and structure Integration tests according to the integration testing guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*Unit.Tests.ps1 : Always add and structure Unit tests according to the unit testing guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : These guidelines apply only to classes decorated with [DscResource(...)]

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : If an integration test requires a SQL Server Database Engine, start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In CI, use Get-ComputerName for computer names

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Always call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine in integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Ensure integration tests cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
🧬 Code graph analysis (4)
tests/Integration/Commands/README.md (1)
tests/Unit/Stubs/SMO.cs (1)
  • Microsoft (1502-1656)
tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (10)
  • Alert (1611-1653)
  • Microsoft (1502-1656)
  • AlertCollection (1568-1602)
  • Alter (766-772)
  • Alert (1648-1648)
  • Add (1589-1589)
  • Alter (714-720)
  • Microsoft (1089-1500)
  • Microsoft (12-1051)
  • JobServer (1542-1562)
source/en-US/SqlServerDsc.strings.psd1 (1)
tests/Unit/Stubs/SMO.cs (2)
  • Microsoft (1502-1656)
  • Alert (1611-1653)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (1)
tests/Unit/Stubs/SMO.cs (6)
  • Alert (1611-1653)
  • Microsoft (1502-1656)
  • Alert (1615-1618)
  • Add (1589-1589)
  • Alert (1648-1648)
  • AlertType (1514-1520)
🪛 markdownlint-cli2 (0.17.2)
.github/instructions/SqlServerDsc-guidelines.instructions.md

8-8: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


9-9: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


13-13: Line length
Expected: 80; Actual: 111

(MD013, line-length)


37-37: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (4)
tests/Integration/Commands/README.md (1)

66-67: CI wiring confirmed: integration tests exist and are included in pipeline

tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (2)

29-30: CI flag handling LGTM.

Sets and removes $env:SqlServerDscCI per unit-test guideline.

Also applies to: 47-48


131-131: Approve code changes
Production invokes Test-SqlDscIsAgentAlert at source/Public/New-SqlDscAgentAlert.ps1:93 and the test mocks/assertions align with the updated existence-check flow.

source/en-US/SqlServerDsc.strings.psd1 (1)

437-441: Rename and IDs look consistent (TSIAA0001–0003).

Keys align with the simplified “exists” semantics and follow the Verb_Function_Action pattern. No issues.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (1)

26-36: Set and clean up $env:SqlServerDscCI per unit test requirements.

Tests must set the CI flag in BeforeAll and remove it in AfterAll.

 BeforeAll {
     $script:dscModuleName = 'SqlServerDsc'
 
     Import-Module -Name $script:dscModuleName -Force -ErrorAction 'Stop'
 
     # Load SMO stub types
     Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"
 
+    # Signal CI context as required by SqlServerDsc unit test guidelines
+    $env:SqlServerDscCI = 'True'
 
     $PSDefaultParameterValues['Mock:ModuleName'] = $script:dscModuleName
     $PSDefaultParameterValues['Should:ModuleName'] = $script:dscModuleName
 }
@@
     # Unload the module being tested so that it doesn't impact any other tests.
     Get-Module -Name $script:dscModuleName -All | Remove-Module -Force
+
+    # Clean up CI environment variable
+    Remove-Item -Path Env:SqlServerDscCI -ErrorAction SilentlyContinue
 }

Also applies to: 38-44

♻️ Duplicate comments (1)
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

6-16: Correct build command flags and wrap long list items; add required blank lines (MD013/MD022/MD032).

  • Use -Tasks (plural) for build script.
  • Wrap long items to ≤ ~80 chars.
  • Add blank line after the heading and before the list.
-# SqlServerDsc Requirements
-
-## Build & Test Workflow Requirements
-- Run in `pwsh`
-- Run scripts from project root
-- Setup build and test environment (once per `pwsh` session): `./build.ps1 -Task noop`
-- Build project: `./build.ps1 -Task build`
-- Run tests without coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
-- Run QA tests: `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
-- Never run integration tests locally
+# SqlServerDsc Requirements
+
+## Build & Test Workflow Requirements
+
+- Run in `pwsh`
+
+- Run scripts from project root
+
+- Setup build and test environment (once per `pwsh` session):
+  `./build.ps1 -Tasks noop`
+
+- Build project:
+  `./build.ps1 -Tasks build`
+
+- Run tests without coverage (wildcards allowed):
+  `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
+
+- Run QA tests:
+  `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
+
+- Never run integration tests locally
🧹 Nitpick comments (7)
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (3)

67-68: Wrap long bullets to satisfy MD013; guidance itself looks good

Content aligns with prior learnings (repeat INPUTS/OUTPUTS per type with 1‑line descriptions) but exceeds the 80‑char limit. Wrap for readability/lint compliance.

- - INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description. Repeat keyword for each input type.
+ - INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line
+   description. Repeat keyword for each input type.
- - OUTPUTS: List each return type (one per line) with a 1‑line description. Repeat keyword for each output type. Must match both `[OutputType()]` and actual returns.
+ - OUTPUTS: List each return type (one per line) with a 1‑line
+   description. Repeat keyword for each output type. Must match both
+   `[OutputType()]` and actual returns.

95-97: Wrap long line and soften “always return after Write-Error”

Line 96 breaks MD013; also, mandating “always return” removes scenarios where collecting multiple non‑terminating errors is intended. Recommend conditional guidance.

 - Use `Write-Error` for non-terminating errors
-  - Always include `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID matching localized string ID), `-TargetObject` (object causing error)
-  - Always use `return` after `Write-Error` to avoid further processing
+  - Always include `-Message` (localized string), `-Category` (relevant
+    error category), `-ErrorId` (unique ID matching localized string ID),
+    `-TargetObject` (object causing error)
+  - Return after `Write-Error` when further processing would be invalid;
+    otherwise guard state‑changing code behind success checks

162-162: Keep the example’s OutputType in sync with multiple OUTPUTS

The example shows two OUTPUTS types but [OutputType()] lists one. Make the attribute reflect the multiple types, or reduce the example to a single type. Suggest updating the attribute for consistency.

-    [OutputType([System.String])]
+    [OutputType([TypeName1], [TypeName2])]
.github/instructions/dsc-community-style-guidelines.instructions.md (1)

14-15: Fix MD032: add a blank line before the list under “Build & Test Workflow”.

Add a blank line after the heading so the list is surrounded by blank lines.

 ## Build & Test Workflow
+
 - Run scripts in `pwsh`; always from repository root
 - Build before running tests: `./build.ps1 -Tasks build`
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

37-37: Add blank line before the “Tests Requirements” heading (MD022).

-## Tests Requirements
+
+## Tests Requirements
tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (2)

69-104: Optionally assert OutputType is [System.Boolean] to match function contract.

         It 'Should have MessageId as an optional parameter' {
             $parameterInfo = (Get-Command -Name 'Test-SqlDscAgentAlertProperty').Parameters['MessageId']
             $parameterInfo.Attributes.Mandatory | Should -BeFalse
         }
+
+        It 'Should declare [OutputType([System.Boolean])]' {
+            $outputTypes = (Get-Command -Name 'Test-SqlDscAgentAlertProperty').OutputType
+            ($outputTypes.Type -match 'System.Boolean') | Should -BeTrue
+        }

48-66: Reduce brittleness of parameter set string assertions (optional).

Comparing ParameterSet.ToString() to an exact string is fragile. Prefer asserting parameter presence and attributes (names, types, Mandatory, ValueFromPipeline, ParameterSetName).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98cba99 and a411af0.

📒 Files selected for processing (7)
  • .github/instructions/SqlServerDsc-guidelines.instructions.md (2 hunks)
  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md (4 hunks)
  • .github/instructions/dsc-community-style-guidelines.instructions.md (1 hunks)
  • source/Public/Test-SqlDscAgentAlertProperty.ps1 (3 hunks)
  • source/Public/Test-SqlDscIsAgentAlert.ps1 (1 hunks)
  • source/en-US/SqlServerDsc.strings.psd1 (1 hunks)
  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (8 hunks)
✅ Files skipped from review due to trivial changes (1)
  • source/Public/Test-SqlDscAgentAlertProperty.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • source/Public/Test-SqlDscIsAgentAlert.ps1
🧰 Additional context used
📓 Path-based instructions (14)
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow PowerShell code style guidelines in all PowerShell scripts, modules, and manifests

**/*.{ps1,psm1,psd1}: End files with exactly one trailing blank line
Use CRLF line endings
Allow at most two consecutive newlines in files
Use UTF-8 encoding without BOM for all files

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow test patterns strictly for maintainability in Pester tests

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
**/*.{ps1,psm1}

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.{ps1,psm1}: Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}
Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)
Always prefer SMO over T-SQL for SQL Server interaction

**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names: PascalCase with Verb-Noun format using approved verbs
Parameter names: PascalCase
Variable names: camelCase
Keywords must be lower-case
Class names: PascalCase
Include scope prefix for script/global/environment variables: $script:, $global:, $env:
Use 4 spaces for indentation (no tabs)
Use one space around operators (e.g., $a = 1 + 2)
Use one space between type and variable (e.g., [String] $name)
Use one space between keyword and parenthesis (e.g., if ($condition))
No spaces on empty lines
Try to limit lines to 120 characters
Place opening brace on a new line (except in variable assignments)
Add one newline after an opening brace
Add two newlines after a closing brace (one if followed by another brace or continuation)
Use single quotes unless variable expansion is needed
Arrays: single-line as @('one','two'), multi-line with one element per line and proper indentation
Do not use unary comma in return statements to force an array
Hashtables: empty as @{}; otherwise each property on its own line with proper indentation; property names in PascalCase
Comments: use '# Comment' (capitalized) on its own line for single-line comments
Multi-line comments use <# #> with opening/closing on their own lines; indent comment text
Do not commit commented-out code
Always add comment-based help to all functions and scripts
Comment-based help must include: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class
Comment-based help indentation: keywords indented 4 spaces; text indented 8 spaces
Include examples for all parameter sets and combinations in comment-based help
In comment-based help, INPUTS: list each pipeline-accepted type (o...

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
tests/Unit/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

tests/Unit/**/*.ps1: In unit tests, use SMO stub types from SMO.cs and never mock real SMO types
Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll
Load SMO stub types in unit tests, e.g., Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
tests/Unit/@(Classes|Public|Private)/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Place unit tests in tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
**/*.{ps1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Localize all strings using string keys and remove any orphaned string keys

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
tests/Unit/**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Add unit tests for all commands, functions, and resources

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
**/*.[Tt]ests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

**/*.[Tt]ests.ps1: Use Pester v5 syntax only
Test code only inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of pipeline)
The tested entity must be called from within It blocks
Keep results and assertions in the same It block
Avoid try-catch-finally for cleanup; use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles in tests
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should' and must not contain 'when'
Prefix mock variables with 'mock'
Each class method should have a separate Context block
Each scenario should have a separate Context block
Use nested Context blocks for complex scenarios
Do mocking in BeforeAll (use BeforeEach only when required)
Place setup/teardown hooks (BeforeAll, BeforeEach, AfterAll, AfterEach) close to usage
Use PascalCase for Pester keywords: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Prefer Should -BeTrue / -BeFalse over -Be $true / -Be $false
Never use Assert-MockCalled; use Should -Invoke instead
Do not use Should -Not -Throw; invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
Omit -ModuleName parameter on Pester commands
Never use Mock inside an InModuleScope block
Define variables for -ForEach in a separate BeforeDiscovery close to usage
Use -ForEach only on Context and It blocks
Keep variable scope close to the usage context
Use BeforeEach and AfterEach sparingly
Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core Requirements

  • All public commands, private functions and classes must have unit tests
  • All public commands and class-based resources must have integration tests
  • Use Pester v5 syntax only
  • Test code only inside Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions start with 'Should', must not contain 'when'
  • Mock variables prefix: 'mock'

Structure & Scope

  • Public commands: Never use InModuleScope (unless retrieving localized strings)
  • Private functions/class resources: Always use InModuleScope
  • Each class method = separate Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Prefer -BeTrue/-BeFalse over -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModule...

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
tests/Unit/Public/**/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

For public commands, never use InModuleScope (except for retrieving localized strings)

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
tests/Unit/Public/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

Place public command unit tests at tests/Unit/Public/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow

  • Run scripts in pwsh; always from repository root
  • Build before running tests: .\build.ps1 -Tasks build
  • Always run tests in new PowerShell session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
**/*.ps?(m|d)1

⚙️ CodeRabbit configuration file

**/*.ps?(m|d)1: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description.
  • OUTPUTS: Lis...

Files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • source/en-US/SqlServerDsc.strings.psd1
source/en-US/*.strings.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)

source/en-US/*.strings.psd1: Store command/function localization in source/en-US/{MyModuleName}.strings.psd1
Store class localization in source/en-US/{ResourceClassName}.strings.psd1
Name localization keys as Verb_FunctionName_Action using underscores (e.g., Get_Database_ConnectingToDatabase)
Define strings using ConvertFrom-StringData with entries like KeyName = Message with {0} placeholder. (PREFIX0001)
Include string IDs in the form (PREFIX####), where PREFIX is initials from the class/function name and numbers are sequential from 0001

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**/*.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

In module manifests, do not use NestedModules for shared commands without specifying RootModule

Files:

  • source/en-US/SqlServerDsc.strings.psd1
🧠 Learnings (78)
📚 Learning: 2025-08-29T17:24:39.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:24:39.268Z
Learning: Applies to tests/[u]Unit/**/*.[Tt]ests.ps1 : Add Parameter Properties tests (e.g., assert Mandatory on parameters) as shown in the template

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.759Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.759Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters to avoid prompts

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Keep variable scope close to the usage context

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Assign function results to variables rather than inline calls

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define variables for -ForEach in a separate BeforeDiscovery close to usage

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*.Tests.ps1 : Follow test patterns strictly for maintainability in Pester tests

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:24:39.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:24:39.268Z
Learning: Applies to tests/[u]Unit/**/*.[Tt]ests.ps1 : For commands with multiple parameter sets, use the same validation template with multiple hashtables in -ForEach

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Inside It blocks, assign unused return objects to $null (unless part of pipeline)

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use BeforeEach and AfterEach sparingly

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:24:39.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:24:39.268Z
Learning: Applies to tests/[u]Unit/**/*.[Tt]ests.ps1 : Use the provided Parameter Set Validation test template for single-parameter-set commands

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:24:39.268Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:24:39.268Z
Learning: Applies to tests/[u]Unit/**/*.[Tt]ests.ps1 : All public commands must have parameter set validation tests

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-16T13:22:15.230Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: tests/Unit/Public/Get-SqlDscLogin.Tests.ps1:78-93
Timestamp: 2025-08-16T13:22:15.230Z
Learning: In PowerShell unit tests for parameter validation in SqlServerDsc, accessing parameter attributes directly like `$cmd.Parameters['ParameterName'].Attributes.Mandatory` works correctly because PowerShell automatically iterates through the array and returns the property values. Additional filtering to ParameterAttribute is not necessary when the parameter structure is known and controlled.

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-25T10:07:22.349Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-08-25T10:07:22.349Z
Learning: Applies to source/DSCResources/**/*.psm1 : Set-TargetResource and Test-TargetResource must have identical parameter sets

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-17T10:15:48.194Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2136
File: tests/Unit/Public/Remove-SqlDscLogin.Tests.ps1:36-39
Timestamp: 2025-08-17T10:15:48.194Z
Learning: Public command unit tests guideline: Never use InModuleScope unless accessing localized strings from $script:localizedData. PSDefaultParameterValues for InModuleScope should be kept in public command tests to support localized string retrieval when necessary.

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Pipeline parameters (ValueFromPipeline = $true) must be declared in ALL parameter sets

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : All parameters must use [Parameter()] and mandatory ones use [Parameter(Mandatory = $true)]

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions in Pester

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit -MockWith when returning $null

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Prefer Should -BeTrue / -BeFalse over -Be $true / -Be $false

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-25T10:07:22.349Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-mof-resources.instructions.md:0-0
Timestamp: 2025-08-25T10:07:22.349Z
Learning: Applies to source/DSCResources/**/*.psm1 : Test-TargetResource must return a boolean ($true/$false)

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-09-05T18:38:09.759Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.759Z
Learning: Applies to **/*.[Tt]ests.ps1 : Assertions only in It blocks

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-28T15:42:41.195Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: source/Classes/020.SqlAgentAlert.ps1:0-0
Timestamp: 2025-08-28T15:42:41.195Z
Learning: Assert-BoundParameter now supports AtLeastOneList parameter (resolved in commit 809953f367ee903969a43e44a5b78e902ef46948) which can be used alongside MutuallyExclusiveList to enforce "exactly one required" validation in DSC resources.

Applied to files:

  • tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Follow SqlServerDsc project-specific guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: SqlServerDsc-specific guidelines override general project guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*Integration.Tests.ps1 : Always add and structure Integration tests according to the integration testing guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*Unit.Tests.ps1 : Always add and structure Unit tests according to the unit testing guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:25:09.959Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:25:09.959Z
Learning: Build before running tests: .\build.ps1 -Tasks build

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Run build and tests from PowerShell at the repository root; build before tests; run tests in a new PowerShell session

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles in tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:25:09.959Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:25:09.959Z
Learning: Run build and tests from PowerShell at the repository root

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use declared variables more than once (avoid single-use locals)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use descriptive names (3+ characters, no abbreviations)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : If an integration test requires a SQL Server Database Engine, start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : In integration tests requiring a SQL Server DB, use Connect-SqlDscDatabaseEngine with correct CI credentials to open the session

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required setup block at the top of each integration test: the SuppressMessage param(), a BeforeDiscovery block that ensures DscResource.Test is available (or runs build.ps1 -Tasks 'noop' and imports it), and a BeforeAll block that sets $script:moduleName and imports the module under test with -Force -ErrorAction Stop

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In CI, use Get-ComputerName for computer names

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Always call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine in integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Ensure integration tests cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help .OUTPUTS sections: Each distinct return type should have its own .OUTPUTS entry with a description of when that type is returned, even if the underlying implementation uses array casting. This follows official PowerShell documentation standards where you list each return type on its own line under .OUTPUTS with clear descriptions of the conditions for each type.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : In comment-based help, OUTPUTS: list each return type (one per line) with a 1-line description and ensure it matches [OutputType()] and actual returns

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help in .OUTPUTS sections: Each distinct type that can be returned should have its own .OUTPUTS entry, even if the implementation technically always returns an array. This follows official PowerShell documentation standards and helps users understand what to expect in different usage scenarios.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : In comment-based help, INPUTS: list each pipeline-accepted type (one per line) with a 1-line description

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help must include: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, and EXAMPLE sections before function/class

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help: In .DESCRIPTION include '## Requirements' and '## Known issues' with link pattern to all open issues for {ResourceName}

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-29T17:19:40.951Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-08-29T17:19:40.951Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Follow PowerShell code style guidelines in all PowerShell scripts, modules, and manifests

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use [OutputType({return type})] for functions with output; use [OutputType()] if no output

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Include examples for all parameter sets and combinations in comment-based help

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Put parameter type on the line above the parameter name

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Host; prefer Write-Verbose/Write-Information/etc.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Output; use return instead

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Avoid aliases; use full command names

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Never use backtick (`) as a line continuation in production code

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use [CmdletBinding(SupportsShouldProcess=$true)] and call $PSCmdlet.ShouldProcess immediately before each state change, following the required message pattern

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Verbose for high-level execution flow and user-actionable information

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Set $ErrorActionPreference = 'Stop' before commands using -ErrorAction 'Stop', then restore after

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Avoid empty catch blocks; instead use -ErrorAction SilentlyContinue where appropriate

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Limit piping to one pipe per line

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Information for user-facing status updates, important operational messages, and non-error state changes

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Error for non-terminating errors with a relevant error category

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use $PSCmdlet.ThrowTerminatingError() for terminating errors (except in classes) with a relevant error category

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use the ShouldProcess required pattern with description, confirmation, and caption messages sourced from localized data and formatted parameters

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-05T18:39:21.939Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-05T18:39:21.939Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Warning for non-fatal issues, deprecated usage, and configuration problems that don't block execution

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Do not use throw for terminating errors; use New-*Exception helpers (New-InvalidDataException, New-ArgumentException, New-InvalidOperationException, New-ObjectNotFoundException, New-InvalidResultException, New-NotImplementedException)

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-06T19:18:18.857Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#0
File: :0-0
Timestamp: 2025-09-06T19:18:18.857Z
Learning: When a PowerShell command uses PSCmdlet.ShouldProcess and is called with -Verbose, the description message from ShouldProcess is automatically output as a verbose message. Therefore, there is no need to use Write-Verbose before or inside PSCmdlet.ShouldProcess blocks as PSCmdlet.ShouldProcess already provides the required verbose message through its description parameter.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : These guidelines apply only to classes decorated with [DscResource(...)]

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:25:09.959Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:25:09.959Z
Learning: Applies to tests/Unit/**/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/020.*.ps1 : Place each DSC class-based resource in file: source/Classes/020.{ResourceName}.ps1

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-05T18:38:09.760Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-05T18:38:09.760Z
Learning: Applies to tests/Unit/Classes/*.Tests.ps1 : Place class resource unit tests at tests/Unit/Classes/{Name}.Tests.ps1

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:21:35.582Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-08-29T17:21:35.582Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : DSC resource classes must inherit ResourceBase (from DscResource.Base)

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
🧬 Code graph analysis (2)
tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 (1)
tests/Unit/Stubs/SMO.cs (2)
  • Alert (1611-1653)
  • Microsoft (1502-1656)
source/en-US/SqlServerDsc.strings.psd1 (1)
tests/Unit/Stubs/SMO.cs (2)
  • Microsoft (1502-1656)
  • Alert (1611-1653)
🪛 markdownlint-cli2 (0.17.2)
.github/instructions/SqlServerDsc-guidelines.instructions.md

8-8: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


9-9: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


11-11: Line length
Expected: 80; Actual: 86

(MD013, line-length)


13-13: Line length
Expected: 80; Actual: 111

(MD013, line-length)


37-37: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

.github/instructions/dsc-community-style-guidelines-powershell.instructions.md

67-67: Line length
Expected: 80; Actual: 120

(MD013, line-length)


68-68: Line length
Expected: 80; Actual: 164

(MD013, line-length)


96-96: Line length
Expected: 80; Actual: 180

(MD013, line-length)

.github/instructions/dsc-community-style-guidelines.instructions.md

14-14: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (2)
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (1)

139-147: Example INPUTS/OUTPUTS pattern: nice clarity

The repeated .INPUTS/.OUTPUTS blocks per type are clear and align with the guidance above. LGTM.

Also applies to: 149-157

source/en-US/SqlServerDsc.strings.psd1 (1)

437-441: LGTM: New TSIAA keys are consistent and sequential

The Test-SqlDscIsAgentAlert block reads well; IDs TSIAA0001–0003 start at 0001 and align with the rename/scope.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (1)

202-203: Inconsistency: Pipeline input tests still reference old command.

These tests still reference Get-AgentAlertObject in the assertions, but based on the PR changes, they should be updated to reference Test-SqlDscIsAgentAlert for consistency.

Apply this diff to fix the inconsistent command references:

-                Should -Invoke -CommandName 'Get-AgentAlertObject' -Times 1 -Exactly
+                Should -Invoke -CommandName 'Test-SqlDscIsAgentAlert' -Times 1 -Exactly

Also applies to: 210-211, 227-228

♻️ Duplicate comments (2)
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (1)

86-86: Add manifest export note for aliases.

Document that aliases must be exported via the module manifest when exports aren’t wildcarded.

- - Use `[Alias()]` attribute for function aliases, never `Set-Alias` or `New-Alias`
+ - Use `[Alias()]` attribute for function aliases, never `Set-Alias` or `New-Alias`
+   - If the module manifest restricts exports, include alias names in `AliasesToExport`
+     (or set `AliasesToExport = '*'`) so aliases load with the module.

Run to verify the alias is exported:

#!/bin/bash
# Check manifest(s) for AliasesToExport and presence of Test-SqlDscAgentAlert
rg -n --type=psd1 -C3 'AliasesToExport'
rg -n --type=psd1 -N 'Test-SqlDscAgentAlert'
source/en-US/SqlServerDsc.strings.psd1 (1)

465-471: Fix ID sequencing and ensure consistency across codebase.

The coding guidelines specify that localization IDs should start at 0001 and be sequential. Based on the past review comments, there are inconsistencies in the ID prefixes and numbering that need to be resolved:

  1. Line 471: Change TSDAAP0001TSAAP0001 to align with the established pattern (other AgentAlert prefixes omit the "D" in SqlDsc)
  2. Ensure all related code and tests use the same corrected ID

Apply this diff to fix the ID prefix:

-    Test_SqlDscAgentAlertProperty_AlertNotFound = SQL Agent Alert '{0}' was not found. (TSDAAP0001)
+    Test_SqlDscAgentAlertProperty_AlertNotFound = SQL Agent Alert '{0}' was not found. (TSAAP0001)

The corresponding code in source/Public/Test-SqlDscAgentAlertProperty.ps1 and tests in tests/Unit/Public/Test-SqlDscAgentAlertProperty.Tests.ps1 also need to be updated to use TSAAP0001 for consistency.

🧹 Nitpick comments (1)
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (1)

96-99: Augment Write-Error guidance to preserve exception details.

Add a note to include the original exception when available.

   - Always include `-Message` (localized string), `-Category` (relevant error category), `-ErrorId` (unique ID matching localized string ID), `-TargetObject` (object causing error)
   - Always use `return` after `Write-Error` to avoid further processing
+  - In catch blocks, pass the original exception using `-Exception $_.Exception` to preserve stack and inner exceptions
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a411af0 and 4274176.

📒 Files selected for processing (8)
  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md (4 hunks)
  • CHANGELOG.md (3 hunks)
  • azure-pipelines.yml (1 hunks)
  • source/Public/New-SqlDscAgentAlert.ps1 (1 hunks)
  • source/en-US/SqlServerDsc.strings.psd1 (1 hunks)
  • tests/Integration/Commands/README.md (1 hunks)
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (8 hunks)
  • tests/Unit/Stubs/SMO.cs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/Unit/Stubs/SMO.cs
🚧 Files skipped from review as they are similar to previous changes (4)
  • source/Public/New-SqlDscAgentAlert.ps1
  • azure-pipelines.yml
  • tests/Integration/Commands/README.md
  • CHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (12)
source/en-US/*.strings.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)

source/en-US/*.strings.psd1: Store command/function localization in source/en-US/{MyModuleName}.strings.psd1
Store class localization in source/en-US/{ResourceClassName}.strings.psd1
Name localization keys as Verb_FunctionName_Action using underscores (e.g., Get_Database_ConnectingToDatabase)
Define strings using ConvertFrom-StringData with entries like KeyName = Message with {0} placeholder. (PREFIX0001)
Include string IDs in the form (PREFIX####), where PREFIX is initials from the class/function name and numbers are sequential from 0001

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: End files with exactly one trailing blank line
Use CR+LF line endings
Allow a maximum of two consecutive newlines
No trailing whitespace on any line
Use UTF-8 encoding without BOM for all files

Follow PowerShell style and test guideline instructions strictly

Files:

  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

Do not use NestedModules for shared commands without setting RootModule in the module manifest

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**/*.strings.psd1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Remove any orphaned string keys from localization data files

Files:

  • source/en-US/SqlServerDsc.strings.psd1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow

  • Run scripts in pwsh; always from repository root
  • Build before running tests: .\build.ps1 -Tasks build
  • Always run tests in new PowerShell session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.ps?(m|d)1

⚙️ CodeRabbit configuration file

**/*.ps?(m|d)1: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description.
  • OUTPUTS: Lis...

Files:

  • source/en-US/SqlServerDsc.strings.psd1
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.{ps1,psm1}

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.{ps1,psm1}: Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}
Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)
Always prefer SMO over T-SQL for SQL Server interaction

**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names use PascalCase with Approved Verb-Noun format
Parameter names use PascalCase
Variable names use camelCase
Keywords are lower-case
Class names use PascalCase
Include scope qualifier for script/global/environment variables: $script:, $global:, $env:
Use 4 spaces for indentation (no tabs)
One space around operators (e.g., $a = 1 + 2)
One space between type and variable (e.g., [String] $name)
One space between keyword and parenthesis (e.g., if ($condition))
No spaces on empty lines
Limit lines to 120 characters where possible
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by brace or continuation)
Use single quotes unless variable expansion is needed
Arrays: single-line as @('one','two'), multi-line with one element per line and proper indentation
Do not use the unary comma operator in return statements to force an array
Hashtables: @{} for empty; each property on its own line and indented; property names PascalCase
Single-line comments start with #, capitalized, on their own line
Multi-line comments use <# #>, with opening/closing on their own lines and indented text
No commented-out code
Always add comment-based help to all functions and scripts
Comment-based help sections: SYNOPSIS, 40+ char DESCRIPTION, PARAMETER, EXAMPLE before function/class
Comment-based help indentation: keywords at 4 spaces, text at 8 spaces
Include examples for all parameter sets and combinations in help
INPUTS: list each pipeline-accepted type with a one-line description
OUTPUTS: list each return type with a one-line description; must match [OutputType()] and actual returns
.NOTES onl...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

tests/Unit/**/*.ps1: In unit tests, use SMO stub types from SMO.cs and never mock real SMO types
Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll
Load SMO stub types in unit tests, e.g., Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
**/*.[Tt]ests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

**/*.[Tt]ests.ps1: All public commands, private functions, and classes must have unit tests
All public commands and class-based resources must have integration tests
Use Pester v5 syntax only
Test code only inside Describe blocks
Assertions only in It blocks
Never test verbose messages, debug messages, or parameter binding behavior
Pass all mandatory parameters to avoid prompts
Inside It blocks, assign unused return objects to $null (unless part of a pipeline)
Call the tested entity from within the It blocks
Keep results and assertions in the same It block
Avoid try/catch/finally for cleanup; use AfterAll or AfterEach
Avoid unnecessary remove/recreate cycles
One Describe block per file matching the tested entity name
Context descriptions start with 'When'
It descriptions start with 'Should' and must not contain 'when'
Mock variables must be prefixed with 'mock'
Public commands: never use InModuleScope (except for retrieving localized strings)
Private functions and class resources: always use InModuleScope
Each class method gets a separate Context block
Each scenario gets a separate Context block
Use nested Context blocks for complex scenarios
Perform mocking in BeforeAll (use BeforeEach only when required)
Place setup/teardown (BeforeAll/BeforeEach/AfterAll/AfterEach) close to usage
Use PascalCase for Pester keywords: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
Use -BeTrue/-BeFalse; never use -Be $true/-Be $false
Never use Assert-MockCalled; use Should -Invoke instead
Do not use Should -Not -Throw; invoke commands directly
Never add an empty -MockWith block
Omit -MockWith when returning $null
Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, and InModuleScope:ModuleName
Omit the -ModuleName parameter on Pester commands
Never use Mock inside an InModuleScope block
Define variables for -ForEach in a separate BeforeDiscovery near usage
Use -ForEach only on Context and It blocks
Keep variable scope close to the usage c...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1

⚙️ CodeRabbit configuration file

**/*.[Tt]ests.ps1: # Tests Guidelines

Core Requirements

  • All public commands, private functions and classes must have unit tests
  • All public commands and class-based resources must have integration tests
  • Use Pester v5 syntax only
  • Test code only inside Describe blocks
  • Assertions only in It blocks
  • Never test verbose messages, debug messages or parameter binding behavior
  • Pass all mandatory parameters to avoid prompts

Requirements

  • Inside It blocks, assign unused return objects to $null (unless part of pipeline)
  • Tested entity must be called from within the It blocks
  • Keep results and assertions in same It block
  • Avoid try-catch-finally for cleanup, use AfterAll or AfterEach
  • Avoid unnecessary remove/recreate cycles

Naming

  • One Describe block per file matching the tested entity name
  • Context descriptions start with 'When'
  • It descriptions start with 'Should', must not contain 'when'
  • Mock variables prefix: 'mock'

Structure & Scope

  • Public commands: Never use InModuleScope (unless retrieving localized strings)
  • Private functions/class resources: Always use InModuleScope
  • Each class method = separate Context block
  • Each scenario = separate Context block
  • Use nested Context blocks for complex scenarios
  • Mocking in BeforeAll (BeforeEach only when required)
  • Setup/teardown in BeforeAll,BeforeEach/AfterAll,AfterEach close to usage

Syntax Rules

  • PascalCase: Describe, Context, It, Should, BeforeAll, BeforeEach, AfterAll, AfterEach
  • Use -BeTrue/-BeFalse never -Be $true/-Be $false
  • Never use Assert-MockCalled, use Should -Invoke instead
  • No Should -Not -Throw - invoke commands directly
  • Never add an empty -MockWith block
  • Omit -MockWith when returning $null
  • Set $PSDefaultParameterValues for Mock:ModuleName, Should:ModuleName, InModuleScope:ModuleName
  • Omit -ModuleName parameter on Pester commands
  • Never use Mock inside `InModuleSc...

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/Public/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-pester.instructions.md)

Public command unit tests must reside in tests/Unit/Public/{Name}.Tests.ps1

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/{Unit,unit}/**/*.[Tt]ests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md)

tests/{Unit,unit}/**/*.[Tt]ests.ps1: Use InModuleScope -ScriptBlock { $script:localizedData.Key } when testing localized strings
Use the $TestDrive variable for creating and mocking files/paths in tests
All public commands must have parameter set validation tests
Include the exact setup block (SuppressMessage attribute, param (), BeforeDiscovery, BeforeAll, AfterAll) before the first Describe in each test file
For single-parameter-set commands, include a test that asserts the ParameterSetName and the ParameterListAsString using the provided It -ForEach template
For commands with multiple parameter sets, include multiple hashtables in -ForEach to validate each parameter set
Add parameter property tests, e.g., assert a parameter is mandatory using $parameterInfo.Attributes.Mandatory | Should -BeTrue

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
tests/Unit/{Classes,Public,Private}/*.Tests.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

tests/Unit/{Classes,Public,Private}/*.Tests.ps1: Place unit tests in tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
Add unit tests for all commands, functions, and resources

Files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
🧠 Learnings (55)
📓 Common learnings
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help .OUTPUTS sections: Each distinct return type should have its own .OUTPUTS entry with a description of when that type is returned, even if the underlying implementation uses array casting. This follows official PowerShell documentation standards where you list each return type on its own line under .OUTPUTS with clear descriptions of the conditions for each type.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : .NOTES only when critical (constraints, side effects, security, compatibility, breaking); ≤2 short sentences

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help sections: SYNOPSIS, 40+ char DESCRIPTION, PARAMETER, EXAMPLE before function/class

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help in .OUTPUTS sections: Each distinct type that can be returned should have its own .OUTPUTS entry, even if the implementation technically always returns an array. This follows official PowerShell documentation standards and helps users understand what to expect in different usage scenarios.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid aliases; use full command names

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : OUTPUTS: list each return type with a one-line description; must match [OutputType()] and actual returns

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : INPUTS: list each pipeline-accepted type with a one-line description

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use [OutputType({return type})] for functions with output; use [OutputType()] for functions with no output

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-09T17:15:47.257Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2154
File: source/Public/Disable-SqlDscAgentOperator.ps1:52-63
Timestamp: 2025-09-09T17:15:47.257Z
Learning: In PowerShell comment-based help, use only one .INPUTS keyword followed by each input type on separate lines with descriptions, rather than multiple .INPUTS sections.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:20:14.838Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.838Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Requirements'

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use SupportsShouldProcess, set ConfirmImpact, and place ShouldProcess check immediately before state changes; avoid Write-Verbose inside the ShouldProcess block

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Host; prefer Write-Verbose/Write-Information etc.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Verbose for high-level execution flow and user-actionable info

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Output; use return instead

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Never use backtick (`) as line continuation in production code

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Avoid empty catch blocks; prefer -ErrorAction SilentlyContinue when appropriate

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Set $ErrorActionPreference = 'Stop' before commands using -ErrorAction 'Stop'; restore previous value after

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-06T19:18:18.857Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#0
File: :0-0
Timestamp: 2025-09-06T19:18:18.857Z
Learning: When a PowerShell command uses PSCmdlet.ShouldProcess and is called with -Verbose, the description message from ShouldProcess is automatically output as a verbose message. Therefore, there is no need to use Write-Verbose before or inside PSCmdlet.ShouldProcess blocks as PSCmdlet.ShouldProcess already provides the required verbose message through its description parameter.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Information for user-facing status, important operational messages, and non-error state changes

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Error for non-terminating errors with appropriate category; always return immediately after Write-Error

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use $PSCmdlet.ThrowTerminatingError() for terminating errors (except in classes); choose appropriate error category; in try-catch include exception with localized message

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Warning for non-fatal issues, deprecation, and configuration problems that don't block execution

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Follow the ShouldProcess message pattern for description, confirmation, and caption using localized strings and -f formatting

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:20:14.838Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.838Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : For terminating errors, use New-*Exception cmdlets: New-InvalidDataException, New-ArgumentException, New-InvalidOperationException, New-ObjectNotFoundException, New-InvalidResultException, New-NotImplementedException

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : In unit tests, use SMO stub types from SMO.cs and never mock real SMO types

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Stubs/SMO.cs : After changing SMO.cs (SMO stubs), run tests in a new PowerShell session

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Perform mocking in BeforeAll (use BeforeEach only when required)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Pass all mandatory parameters to avoid prompts

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Define variables for -ForEach in a separate BeforeDiscovery near usage

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Assign function results to variables rather than inline calls

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Keep variable scope close to the usage context in data-driven tests

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Always run tests in a new PowerShell session using Invoke-Pester with detailed output

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:23:24.153Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-12T13:23:24.153Z
Learning: Applies to tests/{Unit,unit}/**/*.[Tt]ests.ps1 : For single-parameter-set commands, include a test that asserts the ParameterSetName and the ParameterListAsString using the provided It -ForEach template

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use $PSDefaultParameterValues only for Pester commands (Describe, Context, It, Mock, Should, InModuleScope)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:23:24.153Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-unit-tests.instructions.md:0-0
Timestamp: 2025-09-12T13:23:24.153Z
Learning: Applies to tests/{Unit,unit}/**/*.[Tt]ests.ps1 : For commands with multiple parameter sets, include multiple hashtables in -ForEach to validate each parameter set

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Load SMO stub types in unit tests, e.g., Add-Type -Path "$PSScriptRoot/../Stubs/SMO.cs"

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Always prefer SMO over T-SQL for SQL Server interaction

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : In integration tests requiring a SQL Server DB, use Connect-SqlDscDatabaseEngine with correct CI credentials to open the session

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Avoid global variables (except $global:DSCMachineStatus)

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required setup block at the top of each integration test: the SuppressMessage param(), a BeforeDiscovery block that ensures DscResource.Test is available (or runs build.ps1 -Tasks 'noop' and imports it), and a BeforeAll block that sets $script:moduleName and imports the module under test with -Force -ErrorAction Stop

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-28T15:44:12.628Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2150
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:35-35
Timestamp: 2025-08-28T15:44:12.628Z
Learning: The SqlServerDsc repository uses RequiredModules.psd1 to specify Pester with Version = 'latest' and AllowPrerelease = $true, ensuring the latest Pester version (well beyond 5.4) is available, which supports Should -Invoke syntax and other modern Pester features.

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Omit -MockWith when returning $null

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Assert-MockCalled; use Should -Invoke instead

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never add an empty -MockWith block

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Never use Mock inside an InModuleScope block

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Mock variables must be prefixed with 'mock'

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-18T13:50:53.789Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2132
File: tests/Unit/Public/New-SqlDscLogin.Tests.ps1:0-0
Timestamp: 2025-08-18T13:50:53.789Z
Learning: In SqlServerDsc unit tests, SMO stub objects can be used to verify method calls like Create() on Login objects by adding mock verifications with Should -Invoke, providing more robust testing than just checking for no exceptions.

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Avoid using ExpectedMessage with Should -Throw assertions in Pester

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
📚 Learning: 2025-08-17T10:13:30.079Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2136
File: source/Public/Remove-SqlDscLogin.ps1:104-108
Timestamp: 2025-08-17T10:13:30.079Z
Learning: In SqlServerDsc unit tests, SMO object stubs (like Login objects) should have properly mocked Parent properties with correct Server stub types and valid InstanceName values, rather than handling null Parent scenarios in production code.

Applied to files:

  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (6)
source/en-US/SqlServerDsc.strings.psd1 (1)

465-468: LGTM! Proper command separation and localization structure.

The restructuring correctly separates the existence-checking functionality (Test-SqlDscIsAgentAlert) from the original Test-SqlDscAgentAlert command, with appropriate ID sequencing (TSIAA0001-0003) and clear, descriptive messages that align with the command's simplified purpose.

tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (5)

131-131: Test mock updated correctly for existence check function.

The mock has been properly updated to use Test-SqlDscIsAgentAlert instead of Get-AgentAlertObject, returning $false to simulate alert non-existence for new alert creation scenarios.


140-140: Mock invocation assertions correctly updated.

The assertions have been properly updated to verify calls to Test-SqlDscIsAgentAlert instead of the previous function, maintaining the same testing logic with the renamed command.

Also applies to: 147-147


176-177: Comments accurately reflect the updated functionality.

The comments correctly describe that Test-SqlDscIsAgentAlert is being called to check alert existence, which aligns with the PR objective to rename and clarify the command's purpose as an existence check.

Also applies to: 189-190


258-258: Mock correctly configured for existing alert scenario.

The mock return value of $true appropriately simulates an existing alert scenario, which should trigger the error condition in the production code.


284-284: WhatIf scenario mock properly configured.

The mock return value of $false is appropriate for WhatIf scenarios where no actual alert existence check should affect the dry-run behavior.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

8-14: Add blank line after heading and fix build flags

  • Insert a blank line after “Build & Test Workflow Requirements”.
  • Prefer .\build.ps1 and -Tasks for both examples to match repository conventions.
 ## Build & Test Workflow Requirements
+- 
 - Run PowerShell script files from repository root
-- Setup build and test environment (once per `pwsh` session): `./build.ps1 -Task noop`
-- Build project before running tests: `./build.ps1 -Tasks build`
+- Setup build and test environment (once per `pwsh` session): `.\build.ps1 -Tasks noop`
+- Build project before running tests: `.\build.ps1 -Tasks build`
 - Run tests without coverage (wildcards allowed): `Invoke-PesterJob -Path '{tests filepath}' -SkipCodeCoverage`
 - Run QA tests: `Invoke-PesterJob -Path 'tests/QA' -SkipCodeCoverage`
 - Never run integration tests locally
🧹 Nitpick comments (4)
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

36-45: Surround list with blank lines to satisfy markdownlint

Add a blank line after the “## Tests Requirements” heading before the list.

-## Tests Requirements
- - Unit tests: Add `$env:SqlServerDscCI = $true` in `BeforeAll`, remove in `AfterAll`
+## Tests Requirements
+
+ - Unit tests: Add `$env:SqlServerDscCI = $true` in `BeforeAll`, remove in `AfterAll`
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (3)

86-86: Document exporting aliases in the module manifest

Add a sub-bullet so aliases load when exports aren’t wildcarded.

 - Use `[Alias()]` attribute for function aliases, never `Set-Alias` or `New-Alias`
+  - If the module manifest limits exports, include alias names in `AliasesToExport`
+    (or set `AliasesToExport = '*'`) so aliases are available when the module loads.

96-99: Error guidance is solid; consider clarifying PS version nuance (optional)

Optionally note that -Exception is available in Windows PowerShell and PowerShell 7+, to avoid confusion.


141-158: Example structure OK; minor consistency tweak (optional)

The example shows multiple .OUTPUTS types; you may mirror that by noting multiple output types in a comment or by demonstrating multiple [OutputType()] entries in the sample for completeness.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4274176 and 74b9634.

📒 Files selected for processing (5)
  • .github/copilot-instructions.md (1 hunks)
  • .github/instructions/SqlServerDsc-guidelines.instructions.md (2 hunks)
  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md (4 hunks)
  • .github/instructions/dsc-community-style-guidelines.instructions.md (1 hunks)
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1 (10 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/copilot-instructions.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Unit/Public/New-SqlDscAgentAlert.Tests.ps1
🧰 Additional context used
🧠 Learnings (50)
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help .OUTPUTS sections: Each distinct return type should have its own .OUTPUTS entry with a description of when that type is returned, even if the underlying implementation uses array casting. This follows official PowerShell documentation standards where you list each return type on its own line under .OUTPUTS with clear descriptions of the conditions for each type.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-08-16T13:15:17.108Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2134
File: source/Public/Get-SqlDscLogin.ps1:27-38
Timestamp: 2025-08-16T13:15:17.108Z
Learning: For PowerShell comment-based help in .OUTPUTS sections: Each distinct type that can be returned should have its own .OUTPUTS entry, even if the implementation technically always returns an array. This follows official PowerShell documentation standards and helps users understand what to expect in different usage scenarios.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-13T10:13:47.094Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#2204
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:67-68
Timestamp: 2025-09-13T10:13:47.094Z
Learning: According to official Microsoft PowerShell documentation, both .INPUTS and .OUTPUTS keywords should be repeated for each type in comment-based help: "Repeat this keyword for each input type" and "Repeat this keyword for each output type". The guideline should instruct to repeat both keywords, not use single blocks.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help sections: SYNOPSIS, 40+ char DESCRIPTION, PARAMETER, EXAMPLE before function/class

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : .NOTES only when critical (constraints, side effects, security, compatibility, breaking); ≤2 short sentences

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid aliases; use full command names

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : INPUTS: list each pipeline-accepted type with a one-line description

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : OUTPUTS: list each return type with a one-line description; must match [OutputType()] and actual returns

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Comment-based help indentation: keywords at 4 spaces, text at 8 spaces

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:20:14.838Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.838Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : Comment-based help .DESCRIPTION must include '## Requirements'

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use [OutputType({return type})] for functions with output; use [OutputType()] for functions with no output

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : For state-changing functions, use SupportsShouldProcess, set ConfirmImpact, and place ShouldProcess check immediately before state changes; avoid Write-Verbose inside the ShouldProcess block

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Host; prefer Write-Verbose/Write-Information etc.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Verbose for high-level execution flow and user-actionable info

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Avoid Write-Output; use return instead

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Never use backtick (`) as line continuation in production code

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Avoid empty catch blocks; prefer -ErrorAction SilentlyContinue when appropriate

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Set $ErrorActionPreference = 'Stop' before commands using -ErrorAction 'Stop'; restore previous value after

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-06T19:18:18.857Z
Learnt from: johlju
PR: dsccommunity/SqlServerDsc#0
File: :0-0
Timestamp: 2025-09-06T19:18:18.857Z
Learning: When a PowerShell command uses PSCmdlet.ShouldProcess and is called with -Verbose, the description message from ShouldProcess is automatically output as a verbose message. Therefore, there is no need to use Write-Verbose before or inside PSCmdlet.ShouldProcess blocks as PSCmdlet.ShouldProcess already provides the required verbose message through its description parameter.

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Information for user-facing status, important operational messages, and non-error state changes

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Error for non-terminating errors with appropriate category; always return immediately after Write-Error

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use $PSCmdlet.ThrowTerminatingError() for terminating errors (except in classes); choose appropriate error category; in try-catch include exception with localized message

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use Write-Warning for non-fatal issues, deprecation, and configuration problems that don't block execution

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Follow the ShouldProcess message pattern for description, confirmation, and caption using localized strings and -f formatting

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:20:14.838Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-class-resource.instructions.md:0-0
Timestamp: 2025-09-12T13:20:14.838Z
Learning: Applies to source/[cC]lasses/**/*.ps1 : For terminating errors, use New-*Exception cmdlets: New-InvalidDataException, New-ArgumentException, New-InvalidOperationException, New-ObjectNotFoundException, New-InvalidResultException, New-NotImplementedException

Applied to files:

  • .github/instructions/dsc-community-style-guidelines-powershell.instructions.md
📚 Learning: 2025-09-12T13:19:33.094Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T13:19:33.094Z
Learning: SqlServerDsc-specific guidelines override general project guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Build before running tests using .\build.ps1 -Tasks build

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Run build and tests in PowerShell from the repository root

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use declared variables more than once (avoid single-use locals)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Use descriptive names (3+ characters, no abbreviations)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions, and classes must have unit tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : If an integration test requires a SQL Server Database Engine, start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : In integration tests requiring a SQL Server DB, use Connect-SqlDscDatabaseEngine with correct CI credentials to open the session

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required setup block at the top of each integration test: the SuppressMessage param(), a BeforeDiscovery block that ensures DscResource.Test is available (or runs build.ps1 -Tasks 'noop' and imports it), and a BeforeAll block that sets $script:moduleName and imports the module under test with -Force -ErrorAction Stop

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In CI, use Get-ComputerName for computer names

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Always call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine in integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Ensure integration tests cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Private functions and class resources: always use InModuleScope

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands and resources

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
🪛 markdownlint-cli2 (0.17.2)
.github/instructions/dsc-community-style-guidelines.instructions.md

13-13: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


14-14: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (1)
.github/instructions/dsc-community-style-guidelines-powershell.instructions.md (1)

67-68: INPUTS/OUTPUTS repetition rule looks correct

Matches official PowerShell guidance to repeat both keywords per type.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (3)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (1)

106-113: Do not Write-Error when alert is not found; return $false with verbose trace.

Tests and boolean-only semantics are better served by avoiding error records on “not found”. Emit verbose and return $false.

-            if ($null -eq $alertObject)
-            {
-                $errorMessage = $script:localizedData.Test_SqlDscAgentAlertProperty_AlertNotFound -f $Name
-
-                Write-Error -Message $errorMessage -Category 'ObjectNotFound' -ErrorId 'TSDAAP0001' -TargetObject $Name
-
-                return $false
-            }
+            if ($null -eq $alertObject)
+            {
+                Write-Verbose -Message ($script:localizedData.Test_SqlDscAgentAlertProperty_AlertNotFound -f $Name)
+                return $false
+            }

If any unit/integration test asserts no errors are written for “not found”, this change is required. Please run the test suite to confirm.

.github/instructions/dsc-community-style-guidelines.instructions.md (1)

13-17: Fix markdown spacing and script path to meet guidelines and lint rules.

  • Add a blank line after the heading (MD022/MD032).
  • Use .\build.ps1 (repo-root path) instead of ./build.ps1 per project guidance.
 ## Build & Test Workflow Requirements
+
 - Run PowerShell script files from repository root
- - Setup build and test environment (once per `pwsh` session): `./build.ps1 -Tasks noop`
- - Build project before running tests: `./build.ps1 -Tasks build`
+ - Setup build and test environment (once per `pwsh` session): `.\build.ps1 -Tasks noop`
+ - Build project before running tests: `.\build.ps1 -Tasks build`
 - Always run tests in new `pwsh` session: `Invoke-Pester -Path @({test paths}) -Output Detailed`
.github/instructions/SqlServerDsc-guidelines.instructions.md (1)

36-45: Surround heading with blank lines; minor heading grammar nit.

  • Add a blank line after the heading (MD022).
  • Nit: Consider “Test Requirements” or “Testing Requirements” for consistency.
-## Tests Requirements
+## Test Requirements
+
 - Unit tests: Add `$env:SqlServerDscCI = $true` in `BeforeAll`, remove in `AfterAll`
🧹 Nitpick comments (2)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (2)

19-26: Document mutual exclusivity for -Severity and -MessageId.

Add an explicit note that these parameters are mutually exclusive so help matches runtime validation.

 .PARAMETER Severity
-        Specifies the expected severity level for the SQL Agent Alert. Valid range is 0 to 25.
+        Specifies the expected severity level for the SQL Agent Alert. Valid range is 0 to 25.
+        Mutually exclusive with -MessageId.

 .PARAMETER MessageId
-        Specifies the expected message ID for the SQL Agent Alert. Valid range is 0 to 2147483647.
+        Specifies the expected message ID for the SQL Agent Alert. Valid range is 0 to 2147483647.
+        Mutually exclusive with -Severity.

66-77: Harden parameter validation (null/empty).

Add ValidateNotNull/ValidateNotNullOrEmpty to prevent nulls from pipeline and empty names.

 [Parameter(ParameterSetName = 'ByServerAndName', Mandatory = $true, ValueFromPipeline = $true)]
+[ValidateNotNull()]
 [Microsoft.SqlServer.Management.Smo.Server]
 $ServerObject,

 [Parameter(ParameterSetName = 'ByServerAndName', Mandatory = $true)]
+[ValidateNotNullOrEmpty()]
 [System.String]
 $Name,

 [Parameter(ParameterSetName = 'ByAlertObject', Mandatory = $true, ValueFromPipeline = $true)]
+[ValidateNotNull()]
 [Microsoft.SqlServer.Management.Smo.Agent.Alert]
 $AlertObject,
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 74b9634 and e9d788c.

📒 Files selected for processing (4)
  • .github/instructions/SqlServerDsc-guidelines.instructions.md (2 hunks)
  • .github/instructions/dsc-community-style-guidelines.instructions.md (1 hunks)
  • source/Public/Test-SqlDscAgentAlertProperty.ps1 (3 hunks)
  • tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1 (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Integration/Commands/Test-SqlDscAgentAlertProperty.Integration.Tests.ps1
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{ps1,psm1}

📄 CodeRabbit inference engine (.github/instructions/SqlServerDsc-guidelines.instructions.md)

**/*.{ps1,psm1}: Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}
Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)
Always prefer SMO over T-SQL for SQL Server interaction

**/*.{ps1,psm1}: Use descriptive names (3+ characters, no abbreviations)
Function names use PascalCase with Approved Verb-Noun format
Parameter names use PascalCase
Variable names use camelCase
Keywords are lower-case
Class names use PascalCase
Include scope qualifier for script/global/environment variables: $script:, $global:, $env:
Use 4 spaces for indentation (no tabs)
One space around operators (e.g., $a = 1 + 2)
One space between type and variable (e.g., [String] $name)
One space between keyword and parenthesis (e.g., if ($condition))
No spaces on empty lines
Limit lines to 120 characters where possible
Newline before opening brace (except variable assignments)
One newline after opening brace
Two newlines after closing brace (one if followed by brace or continuation)
Use single quotes unless variable expansion is needed
Arrays: single-line as @('one','two'), multi-line with one element per line and proper indentation
Do not use the unary comma operator in return statements to force an array
Hashtables: @{} for empty; each property on its own line and indented; property names PascalCase
Single-line comments start with #, capitalized, on their own line
Multi-line comments use <# #>, with opening/closing on their own lines and indented text
No commented-out code
Always add comment-based help to all functions and scripts
Comment-based help sections: SYNOPSIS, 40+ char DESCRIPTION, PARAMETER, EXAMPLE before function/class
Comment-based help indentation: keywords at 4 spaces, text at 8 spaces
Include examples for all parameter sets and combinations in help
INPUTS: list each pipeline-accepted type with a one-line description
OUTPUTS: list each return type with a one-line description; must match [OutputType()] and actual returns
.NOTES onl...

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
source/**/*.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-localization.instructions.md)

source/**/*.ps1: Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning, and $PSCmdlet.ThrowTerminatingError() messages
Use localized string keys instead of hardcoded strings in script output/messages
Assume and use $script:localizedData for accessing localized strings
When emitting messages, reference $script:localizedData.KeyName and format with the -f operator (e.g., Write-Verbose -Message ($script:localizedData.KeyName -f $value1))

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1

⚙️ CodeRabbit configuration file

source/**/*.ps1: # Localization Guidelines

Requirements

  • Localize all Write-Debug, Write-Verbose, Write-Error, Write-Warning and $PSCmdlet.ThrowTerminatingError() messages
  • Use localized string keys, not hardcoded strings
  • Assume $script:localizedData is available

String Files

  • Commands/functions: source/en-US/{MyModuleName}.strings.psd1
  • Class resources: source/en-US/{ResourceClassName}.strings.psd1

Key Naming Patterns

  • Format: Verb_FunctionName_Action (underscore separators), e.g. Get_Database_ConnectingToDatabase

String Format

ConvertFrom-StringData @'
    KeyName = Message with {0} placeholder. (PREFIX0001)
'@

String IDs

  • Format: (PREFIX####)
  • PREFIX: First letter of each word in class or function name (SqlSetup → SS, Get-SqlDscDatabase → GSDD)
  • Number: Sequential from 0001

Usage

Write-Verbose -Message ($script:localizedData.KeyName -f $value1)

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
**/*.{ps1,psm1,psd1}

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines-powershell.instructions.md)

**/*.{ps1,psm1,psd1}: End files with exactly one trailing blank line
Use CR+LF line endings
Allow a maximum of two consecutive newlines
No trailing whitespace on any line
Use UTF-8 encoding without BOM for all files

Follow PowerShell style and test guideline instructions strictly

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
source/Public/*.ps1

📄 CodeRabbit inference engine (.github/instructions/dsc-community-style-guidelines.instructions.md)

Place public commands in source/Public/{CommandName}.ps1

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
**

⚙️ CodeRabbit configuration file

**: # DSC Community Guidelines

Terminology

  • Command: Public command
  • Function: Private function
  • Resource: DSC class-based resource

Build & Test Workflow

  • Run scripts in pwsh; always from repository root
  • Build before running tests: .\build.ps1 -Tasks build
  • Always run tests in new PowerShell session: Invoke-Pester -Path @({test paths}) -Output Detailed

File Organization

  • Public commands: source/Public/{CommandName}.ps1
  • Private functions: source/Private/{FunctionName}.ps1
  • Unit tests: tests/Unit/{Classes|Public|Private}/{Name}.Tests.ps1
  • Integration tests: tests/Integration/Commands/{CommandName}.Integration.Tests.ps1

Requirements

  • Follow instructions over existing code patterns
  • Follow PowerShell style and test guideline instructions strictly
  • Always update CHANGELOG.md Unreleased section
  • Localize all strings using string keys; remove any orphaned string keys
  • Check DscResource.Common before creating private functions
  • Separate reusable logic into private functions
  • DSC resources should always be created as class-based resources
  • Add unit tests for all commands/functions/resources
  • Add integration tests for all public commands and resources

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
**/*.ps?(m|d)1

⚙️ CodeRabbit configuration file

**/*.ps?(m|d)1: # PowerShell Guidelines

Naming

  • Use descriptive names (3+ characters, no abbreviations)
  • Functions: PascalCase with Verb-Noun format using approved verbs
  • Parameters: PascalCase
  • Variables: camelCase
  • Keywords: lower-case
  • Classes: PascalCase
  • Include scope for script/global/environment variables: $script:, $global:, $env:

File naming

  • Class files: ###.ClassName.ps1 format (e.g. 001.SqlReason.ps1, 004.StartupParameters.ps1)

Formatting

Indentation & Spacing

  • Use 4 spaces (no tabs)
  • One space around operators: $a = 1 + 2
  • One space between type and variable: [String] $name
  • One space between keyword and parenthesis: if ($condition)
  • No spaces on empty lines
  • Try to limit lines to 120 characters

Braces

  • Newline before opening brace (except variable assignments)
  • One newline after opening brace
  • Two newlines after closing brace (one if followed by another brace or continuation)

Quotes

  • Use single quotes unless variable expansion is needed: 'text' vs "text $variable"

Arrays

  • Single line: @('one', 'two', 'three')
  • Multi-line: each element on separate line with proper indentation
  • Do not use the unary comma operator (,) in return statements to force
    an array

Hashtables

  • Empty: @{}
  • Each property on separate line with proper indentation
  • Properties: Use PascalCase

Comments

  • Single line: # Comment (capitalized, on own line)
  • Multi-line: <# Comment #> format (opening and closing brackets on own line), and indent text
  • No commented-out code

Comment-based help

  • Always add comment-based help to all functions and scripts
  • Comment-based help: SYNOPSIS, DESCRIPTION (40+ chars), PARAMETER, EXAMPLE sections before function/class
  • Comment-based help indentation: keywords 4 spaces, text 8 spaces
  • Include examples for all parameter sets and combinations
  • INPUTS: List each pipeline‑accepted type (one per line) with a 1‑line description.
  • OUTPUTS: Lis...

Files:

  • source/Public/Test-SqlDscAgentAlertProperty.ps1
🧠 Learnings (25)
📚 Learning: 2025-09-12T13:19:33.094Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T13:19:33.094Z
Learning: SqlServerDsc-specific guidelines override general project guidelines

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Unit/**/*.ps1 : Unit tests must set $env:SqlServerDscCI = $true in BeforeAll and remove it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to **/*.{ps1,psm1,psd1} : Follow PowerShell style and test guideline instructions strictly

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Use DSCSQLTEST (Database Engine), SSRS (Reporting Services), and PBIRS (Power BI Report Server) instance names in CI integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Build before running tests using .\build.ps1 -Tasks build

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Avoid unnecessary remove/recreate cycles

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Run build and tests in PowerShell from the repository root

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Use Pester v5 syntax only

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:22:48.920Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.920Z
Learning: Applies to **/*.{ps1,psm1} : Use declared variables more than once (avoid single-use locals)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:22:48.919Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-powershell.instructions.md:0-0
Timestamp: 2025-09-12T13:22:48.919Z
Learning: Applies to **/*.{ps1,psm1} : Use descriptive names (3+ characters, no abbreviations)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Public PowerShell commands must use the naming format Verb-SqlDsc{Noun}

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to **/*.{ps1,psm1} : Private PowerShell functions must use the naming format Verb-Noun (no SqlDsc infix)

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands and class-based resources must have integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : All public commands, private functions, and classes must have unit tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-10T15:11:52.897Z
Learnt from: dan-hughes
PR: dsccommunity/ActiveDirectoryDsc#741
File: azure-pipelines.yml:104-104
Timestamp: 2025-08-10T15:11:52.897Z
Learning: In the ActiveDirectoryDsc project, HQRM (High Quality Resource Module) tests must run in PowerShell 5 (Windows PowerShell) using `pwsh: false` in the Azure Pipelines configuration, while unit tests can run in PowerShell 7 (PowerShell Core) with `pwsh: true`. This differentiation is intentional due to HQRM's specific requirements and dependencies on Windows PowerShell.

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : If an integration test requires a SQL Server Database Engine, start the Windows service in BeforeAll and stop it in AfterAll

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : In integration tests requiring a SQL Server DB, use Connect-SqlDscDatabaseEngine with correct CI credentials to open the session

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Include the required setup block at the top of each integration test: the SuppressMessage param(), a BeforeDiscovery block that ensures DscResource.Test is available (or runs build.ps1 -Tasks 'noop' and imports it), and a BeforeAll block that sets $script:moduleName and imports the module under test with -Force -ErrorAction Stop

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : In CI, use Get-ComputerName for computer names

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:20:42.266Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/SqlServerDsc-guidelines.instructions.md:0-0
Timestamp: 2025-08-29T17:20:42.266Z
Learning: Applies to tests/Integration/**/*.ps1 : Always call Disconnect-SqlDscDatabaseEngine after Connect-SqlDscDatabaseEngine in integration tests

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-08-29T17:22:07.610Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-integration-tests.instructions.md:0-0
Timestamp: 2025-08-29T17:22:07.610Z
Learning: Applies to tests/[iI]ntegration/**/*.[iI]ntegration.[tT]ests.ps1 : Ensure integration tests cover all scenarios and code paths

Applied to files:

  • .github/instructions/SqlServerDsc-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to tests/Unit/{Classes,Public,Private}/*.Tests.ps1 : Add unit tests for all commands, functions, and resources

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:21:31.040Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines-pester.instructions.md:0-0
Timestamp: 2025-09-12T13:21:31.040Z
Learning: Applies to **/*.[Tt]ests.ps1 : Private functions and class resources: always use InModuleScope

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
📚 Learning: 2025-09-12T13:24:11.333Z
Learnt from: CR
PR: dsccommunity/SqlServerDsc#0
File: .github/instructions/dsc-community-style-guidelines.instructions.md:0-0
Timestamp: 2025-09-12T13:24:11.333Z
Learning: Applies to tests/Integration/Commands/*.Integration.Tests.ps1 : Add integration tests for all public commands and resources

Applied to files:

  • .github/instructions/dsc-community-style-guidelines.instructions.md
🪛 markdownlint-cli2 (0.17.2)
.github/instructions/SqlServerDsc-guidelines.instructions.md

8-8: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


9-9: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)


36-36: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)

.github/instructions/dsc-community-style-guidelines.instructions.md

16-16: Headings should be surrounded by blank lines
Expected: 1; Actual: 0; Below

(MD022, blanks-around-headings)


17-17: Lists should be surrounded by blank lines

(MD032, blanks-around-lists)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: dsccommunity.SqlServerDsc (Build Package Module)
  • GitHub Check: PSScriptAnalyzer
🔇 Additional comments (6)
source/Public/Test-SqlDscAgentAlertProperty.ps1 (4)

3-8: SYNOPSIS/DESCRIPTION clarity is good.

Clear purpose and the “at least one property” constraint is stated.


16-18: AlertObject parameter set addition looks correct.

Good: dedicated ByAlertObject set with pipeline-by-type support.


92-97: Parameter guards are appropriate.

Good use of Assert-BoundParameter for “at least one” and mutual exclusivity.


98-105: Parameter set dispatch is clean.

Straightforward split between AlertObject and Server+Name paths.

.github/instructions/SqlServerDsc-guidelines.instructions.md (2)

6-7: LGTM on title rename.

Header reads clearly and matches file scope.


8-14: Add blank line after heading; use PowerShell path and clarify integration-test policy

  • Add a blank line after the "## Build & Test Workflow Requirements" heading (MD022/MD032).
  • Replace ./build.ps1 with .\build.ps1 for the setup and build lines to match repo-root PowerShell invocation.
  • Annotate Invoke-PesterJob lines with "(requires DscResource.Test)" to make the dependency explicit.
  • Confirm whether "Never run integration tests locally" is intentional; if intentional add a one-line rationale or CI link, otherwise relax/remove the absolute prohibition.

Copy link
Member Author

@johlju johlju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@johlju reviewed 8 of 26 files at r1, 8 of 16 files at r5, 3 of 11 files at r6, 8 of 8 files at r7, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @johlju)

@johlju johlju merged commit 371314d into dsccommunity:main Sep 14, 2025
43 of 44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test-SqlDscIsAgentAlert: Command rename proposal

1 participant