From 1e4a2da8219de3469b26e4d34b15bd40510b98c2 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 26 Nov 2025 17:54:06 -0500 Subject: [PATCH] update tests pester tests pass for all kinds - cast device.sr to int --- lib/device.ps1 | 2 +- tests/higher.Tests.ps1 | 144 +++++++++++++++++++++++++++++++++++------ tests/run.ps1 | 1 + 3 files changed, 127 insertions(+), 20 deletions(-) diff --git a/lib/device.ps1 b/lib/device.ps1 index 5f5525c..aa24c8c 100644 --- a/lib/device.ps1 +++ b/lib/device.ps1 @@ -13,7 +13,7 @@ class Device : IRemote { hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` { - $this.Getter('sr') + [int]$this.Getter('sr') } ` { return Write-Warning ("ERROR: $($this.identifier()).sr is read only") diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index aa825ae..3f2dda0 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -251,39 +251,67 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } - Describe 'Int Tests' -ForEach @( - @{ Index = $phys_in }, @{ Index = $virt_in } - ) { - Context 'Strip, one physical, one virtual' -Skip:$ifBasic -ForEach @( - @{ Value = 3; Expected = 3 } - @{ Value = -6; Expected = -6 } + Describe 'Int Tests' { + Context 'Strip, one physical, one virtual' -ForEach @( + @{ Index = $phys_in }, @{ Index = $virt_in } ) { - It "Should set Strip[$index].Limit to 3" { + It "Should set and get Strip[$index].Limit" -Skip:$ifBasic -ForEach @( + @{ Value = 3; Expected = 3 } + @{ Value = -6; Expected = -6 } + ) { $vmr.strip[$index].limit = $value $vmr.strip[$index].limit | Should -Be $expected } } - Context 'Vban outstream' { - Context 'sr' -ForEach @( + Context 'Strip, physical only' -ForEach @( + @{ Index = $phys_in } + ) { + Context 'Device' { + It "Should get Strip[$index].Device.sr" { + $vmr.strip[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Bus, physical only' -ForEach @( + @{ Index = $phys_out } + ) { + Context 'Device' { + It "Should get Bus[$index].Device.sr" { + $vmr.bus[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Bus, virtual only' -ForEach @( + @{ Index = $virt_out } + ) { + Context 'Device' -Skip:$ifNotBasic { + It "Should get Bus[$index].Device.sr" { + $vmr.bus[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Vban outstream' -ForEach @( + @{ Index = $vban_out } + ) { + It "Should set vban.outstream[$index].sr to $value" -ForEach @( @{ Value = 44100; Expected = 44100 } @{ Value = 48000; Expected = 48000 } ) { - It "Should set vban.outstream[$index].sr to $value" { - $vmr.vban.outstream[$index].sr = $value - $vmr.vban.outstream[$index].sr | Should -Be $expected - } + $vmr.vban.outstream[$index].sr = $value + $vmr.vban.outstream[$index].sr | Should -Be $expected } - Context 'channel' -ForEach @( + It 'Should set vban.outstream[0].channel to 1' -ForEach @( @{ Value = 1; Expected = 1 } @{ Value = 2; Expected = 2 } ) { - It 'Should set vban.outstream[0].channel to 1' { - $vmr.vban.outstream[$index].channel = $value - $vmr.vban.outstream[$index].channel | Should -Be $expected - } - } + $vmr.vban.outstream[$index].channel = $value + $vmr.vban.outstream[$index].channel | Should -Be $expected + } } Context 'Patch' { @@ -341,6 +369,32 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } + Context 'Strip, physical only' -ForEach @( + @{ Index = $phys_in } + ) { + Context 'Device' -ForEach @( + @{ Value = 'testInput' }, @{ Value = '' } + ) { + It "Should set Strip[$index].Device.wdm" { + $vmr.strip[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + + It "Should set Strip[$index].Device.ks" { + $vmr.strip[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + + It "Should set Strip[$index].Device.mme" { + $vmr.strip[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + } + } + Context 'Bus, one physical, one virtual' -ForEach @( @{ Index = $phys_out }, @{ Index = $virt_out } ) { @@ -353,6 +407,58 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } + Context 'Bus, physical only' -ForEach @( + @{ Index = $phys_out } + ) { + Context 'Device' -ForEach @( + @{ Value = 'testOutput' }, @{ Value = '' } + ) { + It "Should set Bus[$index].Device.wdm" { + $vmr.bus[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.ks" { + $vmr.bus[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.mme" { + $vmr.bus[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + } + } + + Context 'Bus, virtual only' -ForEach @( + @{ Index = $virt_out } + ) { + Context 'Device' -Skip:$ifNotBasic -ForEach @( + @{ Value = 'testOutput' }, @{ Value = '' } + ) { + It "Should set Bus[$index].Device.wdm" { + $vmr.bus[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.ks" { + $vmr.bus[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.mme" { + $vmr.bus[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + } + } + Describe 'Vban' -ForEach @( @{ Index = $vban_in } ) { diff --git a/tests/run.ps1 b/tests/run.ps1 index e6fa0a6..e592d91 100644 --- a/tests/run.ps1 +++ b/tests/run.ps1 @@ -21,6 +21,7 @@ function main() { # skip conditions by kind $ifBasic = $vmr.kind.name -eq 'basic' + $ifNotBasic = $vmr.kind.name -ne 'basic' $ifNotPotato = $vmr.kind.name -ne 'potato' Invoke-Pester -Tag $tag -PassThru | Out-Null