tests/Performance.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 'Get-OctaPerformanceActions - MMCSS Games task profile (011-competitive-latency-tuning)' { It 'never throws' { { Get-OctaPerformanceActions } | Should Not Throw } It 'only reports the Games task profile actions whose current value actually differs from target (honest drift-detection, not a forced rewrite)' { $gamesTaskKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks\Games' $targets = @{ 'GPU Priority' = 8; 'Priority' = 6; 'Scheduling Category' = 'High' } $actions = @(Get-OctaPerformanceActions | Where-Object { $_.TargetIdentifier -like "$gamesTaskKey|*" }) foreach ($action in $actions) { $valueName = ($action.TargetIdentifier -split '\|', 2)[1] $current = (Get-ItemProperty -Path $gamesTaskKey -Name $valueName -ErrorAction SilentlyContinue).$valueName $current | Should Not Be $targets[$valueName] $action.RiskLevel | Should Be 'Safe' } } It 'Set-OctaPerformanceAction writes the correct registry type for a Games task value (HKCU scratch key, no elevation needed)' { $scratchKey = 'HKCU:\Software\OctaTestScratch\011' try { $stringAction = New-OctaAction -TargetType Registry -TargetIdentifier "$scratchKey|Scheduling Category" -PlannedValue 'High' Set-OctaPerformanceAction -Action $stringAction (Get-Item -Path $scratchKey).GetValueKind('Scheduling Category') | Should Be 'String' (Get-ItemProperty -Path $scratchKey -Name 'Scheduling Category').'Scheduling Category' | Should Be 'High' $dwordAction = New-OctaAction -TargetType Registry -TargetIdentifier "$scratchKey|Priority" -PlannedValue 6 Set-OctaPerformanceAction -Action $dwordAction (Get-Item -Path $scratchKey).GetValueKind('Priority') | Should Be 'DWord' (Get-ItemProperty -Path $scratchKey -Name 'Priority').Priority | Should Be 6 } finally { Remove-Item -Path $scratchKey -Recurse -Force -ErrorAction SilentlyContinue } } } |