pester tests now support all kinds.

This commit is contained in:
onyx-and-iris 2022-10-27 21:20:51 +01:00
parent 62c65e1c08
commit f7c0e076aa
3 changed files with 73 additions and 46 deletions

View File

@ -4,7 +4,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Value = $false; Expected = $false } @{ Value = $false; Expected = $false }
){ ){
Context 'Strip, one physical one virtual' -ForEach @( Context 'Strip, one physical one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 3 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
It "Should set and get Strip[$index].Mute" { It "Should set and get Strip[$index].Mute" {
$vmr.strip[$index].mute = $value $vmr.strip[$index].mute = $value
@ -16,21 +16,21 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
$vmr.strip[$index].solo | Should -Be $expected $vmr.strip[$index].solo | Should -Be $expected
} }
It "Should set and get Strip[$index].A3" { It "Should set and get Strip[$index].A1" {
$vmr.strip[$index].A3 = $value $vmr.strip[$index].A1 = $value
$vmr.strip[$index].A3 | Should -Be $expected $vmr.strip[$index].A1 | Should -Be $expected
} }
It "Should set and get Strip[$index].B2" { It "Should set and get Strip[$index].B1" {
$vmr.strip[$index].B2 = $value $vmr.strip[$index].B1 = $value
$vmr.strip[$index].B2 | Should -Be $expected $vmr.strip[$index].B1 | Should -Be $expected
} }
} }
Context 'Bus, one physical one virtual' -ForEach @( Context 'Bus, one physical one virtual' -ForEach @(
@{ Index = 2 }, @{ Index = 4 } @{ Index = $phys_out }, @{ Index = $virt_out }
){ ){
It "Should set and get Bus[$index].Eq" { It "Should set and get Bus[$index].Eq" -Skip:$ifBasic {
$vmr.bus[$index].eq = $value $vmr.bus[$index].eq = $value
$vmr.bus[$index].eq | Should -Be $expected $vmr.bus[$index].eq | Should -Be $expected
} }
@ -40,12 +40,12 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
$vmr.bus[$index].mono | Should -Be $expected $vmr.bus[$index].mono | Should -Be $expected
} }
It "Should set and get Bus[$index].mode_amix" { It "Should set and get Bus[$index].mode_amix" -Skip:$ifBasic {
$vmr.bus[$index].mode_amix = $value $vmr.bus[$index].mode_amix = $value
$vmr.bus[$index].mode_amix | Should -Be $expected $vmr.bus[$index].mode_amix | Should -Be $expected
} }
It "Should set and get Bus[$index].mode_centeronly" { It "Should set and get Bus[$index].mode_centeronly" -Skip:$ifBasic {
$vmr.bus[$index].mode_centeronly = $value $vmr.bus[$index].mode_centeronly = $value
$vmr.bus[$index].mode_centeronly | Should -Be $expected $vmr.bus[$index].mode_centeronly | Should -Be $expected
} }
@ -61,7 +61,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Context 'Vban instream' -ForEach @( Context 'Vban instream' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $vban_in }
){ ){
It "Should set vban.instream[$index].on" { It "Should set vban.instream[$index].on" {
$vmr.vban.instream[$index].on = $value $vmr.vban.instream[$index].on = $value
@ -70,7 +70,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Context 'Vban outstream' -ForEach @( Context 'Vban outstream' -ForEach @(
@{ Index = 3 }, @{ Index = 7 } @{ Index = $vban_out }
){ ){
It "Should set vban.outstream[$index].on" { It "Should set vban.outstream[$index].on" {
$vmr.vban.outstream[$index].on = $value $vmr.vban.outstream[$index].on = $value
@ -78,7 +78,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
} }
Context 'Recorder' { Context 'Recorder' -Skip:$ifBasic {
It "Should set and get Recorder.A3" { It "Should set and get Recorder.A3" {
$vmr.recorder.A3 = $value $vmr.recorder.A3 = $value
$vmr.recorder.A3 | Should -Be $expected $vmr.recorder.A3 | Should -Be $expected
@ -104,7 +104,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Describe 'Float Tests' { Describe 'Float Tests' {
Describe 'Strip tests' { Describe 'Strip tests' {
Context 'one physical, one virtual' -ForEach @( Context 'one physical, one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
Context 'gain' -ForEach @( Context 'gain' -ForEach @(
@{ Value = 3.6; Expected = 3.6 }, @{ Value = -8.2; Expected = -8.2 } @{ Value = 3.6; Expected = 3.6 }, @{ Value = -8.2; Expected = -8.2 }
@ -116,8 +116,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
} }
Context 'physical only' -ForEach @( Context 'physical only' -Skip:$ifBasic -ForEach @(
@{ Index = 0 }, @{ Index = 1 } @{ Index = $phys_in }
){ ){
Context 'comp, gate' -ForEach @( Context 'comp, gate' -ForEach @(
@{ Value = 8.3; Expected = 8.3 }, @{ Value = 5.1; Expected = 5.1 } @{ Value = 8.3; Expected = 8.3 }, @{ Value = 5.1; Expected = 5.1 }
@ -137,7 +137,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Describe 'Bus tests' { Describe 'Bus tests' {
Context 'one physical, one virtual' -ForEach @( Context 'one physical, one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_out }, @{ Index = $virt_out }
){ ){
Context 'gain' -ForEach @( Context 'gain' -ForEach @(
@{ Value = 5.2; Expected = 5.2 }, @{ Value = -38.2; Expected = -38.2 } @{ Value = 5.2; Expected = 5.2 }, @{ Value = -38.2; Expected = -38.2 }
@ -152,9 +152,9 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Describe 'Int Tests' -ForEach @( Describe 'Int Tests' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
Context 'Strip, one physical, one virtual' -ForEach @( Context 'Strip, one physical, one virtual' -Skip:$ifBasic -ForEach @(
@{ Value = 3; Expected = 3 } @{ Value = 3; Expected = 3 }
@{ Value = -6; Expected = -6 } @{ Value = -6; Expected = -6 }
){ ){
@ -189,7 +189,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Describe 'String Tests' { Describe 'String Tests' {
Context 'Strip, one physical, one virtual' -ForEach @( Context 'Strip, one physical, one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
It "Should set Strip[$index].Label" -ForEach @( It "Should set Strip[$index].Label" -ForEach @(
@{ Value = "test0"; Expected = "test0" } @{ Value = "test0"; Expected = "test0" }
@ -201,7 +201,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Context 'Bus, one physical, one virtual' -ForEach @( Context 'Bus, one physical, one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_out }, @{ Index = $virt_out }
){ ){
It "Should set Bus[$index].Label" -ForEach @( It "Should set Bus[$index].Label" -ForEach @(
@{ Value = "test0"; Expected = "test0" } @{ Value = "test0"; Expected = "test0" }
@ -213,7 +213,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
Describe 'Vban' -ForEach @( Describe 'Vban' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $vban_in }
){ ){
Context 'instream' { Context 'instream' {
Context 'ip' -ForEach @( Context 'ip' -ForEach @(

View File

@ -26,7 +26,7 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' {
@{ Value = 0; Expected = 0 } @{ Value = 0; Expected = 0 }
){ ){
Context 'Strip, one physical one virtual' -ForEach @( Context 'Strip, one physical one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
Context 'mute, mono, A1, B2' -ForEach @( Context 'mute, mono, A1, B2' -ForEach @(
@{ param = "mute" }, @{ param = "A1" } @{ param = "mute" }, @{ param = "A1" }
@ -44,7 +44,7 @@ Describe -Tag 'lower', -TestName 'All Lower Tests' {
@{ Value = 'test1'; Expected = 'test1' } @{ Value = 'test1'; Expected = 'test1' }
){ ){
Context 'Strip, one physical one virtual' -ForEach @( Context 'Strip, one physical one virtual' -ForEach @(
@{ Index = 0 }, @{ Index = 4 } @{ Index = $phys_in }, @{ Index = $virt_in }
){ ){
It "Should set Strip[$index].Label to $value" { It "Should set Strip[$index].Label to $value" {
Param_Set -PARAM "Strip[$index].Label" -VALUE $value Param_Set -PARAM "Strip[$index].Label" -VALUE $value

View File

@ -1,4 +1,4 @@
Param([String]$tag, [Int]$num=1, [switch]$log) Param([String]$tag, [Int]$num=1, [switch]$log, [string]$kind)
Import-Module ..\lib\Voicemeeter.psm1 Import-Module ..\lib\Voicemeeter.psm1
Function ParseLog { Function ParseLog {
@ -31,27 +31,54 @@ Function ParseLog {
} }
try function main() {
{ try
$vmr = Get-RemoteBanana {
switch ($kind) {
$logfile = "_results.log" "basic" { $vmr = Get-RemoteBasic }
if (Test-Path $logfile) { Clear-Content $logfile } "banana" { $vmr = Get-RemoteBanana }
"potato" { $vmr = Get-RemotePotato }
1..$num | ForEach-Object {
if ($log) {
"Running test $_ of $num" | Tee-Object -FilePath $logfile -Append
Invoke-Pester -Tag $tag -PassThru | Tee-Object -FilePath $logfile -Append
} }
else { Write-Host "Running tests for $vmr"
"Running test $_ of $num"
Invoke-Pester -Tag $tag -PassThru # test boundaries by kind
$phys_in = $vmr.kind.p_in - 1
$virt_in = $vmr.kind.p_in + $vmr.kind.v_in - 1
$phys_out = $vmr.kind.p_out - 1
$virt_out = $vmr.kind.p_out + $vmr.kind.v_out - 1
$vban_in = $vmr.kind.vban_in - 1
$vban_out = $vmr.kind.vban_out - 1
# skip conditions by kind
$ifBasic = $vmr.kind.name -eq "basic"
$ifBanana = $vmr.kind.name -eq "banana"
$ifPotato = $vmr.kind.name -eq "potato"
$ifNotBasic = $vmr.kind.name -ne "basic"
$ifNotBanana = $vmr.kind.name -ne "banana"
$ifNotPotato = $vmr.kind.name -ne "potato"
$logfile = "_results.log"
if (Test-Path $logfile) { Clear-Content $logfile }
1..$num | ForEach-Object {
if ($log) {
"Running test $_ of $num" | Tee-Object -FilePath $logfile -Append
Invoke-Pester -Tag $tag -PassThru | Tee-Object -FilePath $logfile -Append
}
else {
"Running test $_ of $num"
Invoke-Pester -Tag $tag -PassThru
}
} }
if($log) { Parselog -logfile $logfile }
} }
finally
{
$vmr.Logout()
}
}
if($log) { Parselog -logfile $logfile }
}
finally if ($MyInvocation.InvocationName -ne '.') { main }
{
$vmr.Logout()
}