tests/BackgroundActivity.Tests.ps1

$moduleRoot = Split-Path -Parent $PSScriptRoot
Import-Module (Join-Path $moduleRoot 'Octa.psd1') -Force
. (Join-Path $moduleRoot 'private\ActionHelpers.ps1')
Get-ChildItem -Path (Join-Path $moduleRoot 'categories') -Filter '*.ps1' | ForEach-Object { . $_.FullName }

Describe 'background-activity does not duplicate an existing category (FR-037)' {
    It 'targets no registry value already covered by an existing category' {
        $backgroundActions = Get-OctaBackgroundActivityActions
        $servicesActions = Get-OctaServicesActions
        $overlap = $backgroundActions | Where-Object {
            $ba = $_
            $servicesActions | Where-Object { $_.TargetType -eq $ba.TargetType -and $_.TargetIdentifier -eq $ba.TargetIdentifier }
        }
        $overlap.Count | Should Be 0
    }
}

Describe 'Services category Delivery Optimization fix (008)' {
    It 'DoSvc is no longer a Service-typed action in the catalog (Set-Service was confirmed rejected by its ACL)' {
        ($script:OctaServicesCatalog | Where-Object { $_.Name -eq 'DoSvc' }) | Should Be $null
    }

    It 'offers Delivery Optimization as a Registry-typed Group Policy action instead' {
        $actions = Get-OctaServicesActions
        $doAction = $actions | Where-Object { $_.TargetIdentifier -match 'DeliveryOptimization' }
        if ($doAction) {
            $doAction.TargetType | Should Be 'Registry'
        }
    }
}