AddActionMembers

changed AddActionMembers to add ScriptMethod members; this is a breaking change
This commit is contained in:
pblivingston 2025-12-01 20:23:38 -05:00
parent df2d1bb156
commit 0fbd41ac0b
2 changed files with 10 additions and 14 deletions

View File

@ -66,14 +66,10 @@ function AddActionMembers () {
param( param(
[String[]]$PARAMS [String[]]$PARAMS
) )
[hashtable]$Signatures = @{}
foreach ($param in $PARAMS) { foreach ($param in $PARAMS) {
# Define getter $this | Add-Member -MemberType ScriptMethod -Name $param `
$Signatures['Getter'] = "`$this.Setter('{0}', `$true)" -f $param -Value ([scriptblock]::Create("`$null = `$this.Setter('$param', 1)")) `
# Define setter -Force
$Signatures['Setter'] = ''
Addmember
} }
} }

View File

@ -119,7 +119,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Context 'Vban' { Context 'Vban' {
It 'Should set and get Vban.enable' { It 'Should set and get Vban.enable' {
$vmr.vban.enable = $value $vmr.vban.enable = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.vban.enable | Should -Be $expected $vmr.vban.enable | Should -Be $expected
} }
@ -214,14 +214,14 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
Context 'Option' { Context 'Option' {
It 'Should set and get Option.monitoronsel' -Skip:$ifNotPotato { It 'Should set and get Option.monitoronsel' -Skip:$ifNotPotato {
$vmr.option.monitoronsel = $value $vmr.option.monitoronsel = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.option.monitoronsel | Should -Be $value $vmr.option.monitoronsel | Should -Be $value
} }
It 'Should set and get Option.slidermode' -Skip:$ifNotPotato { It 'Should set and get Option.slidermode' -Skip:$ifNotPotato {
$vmr.option.slidermode = $value $vmr.option.slidermode = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.option.slidermode | Should -Be $value $vmr.option.slidermode | Should -Be $value
} }
@ -361,7 +361,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Value = 486.57 }, @{ Value = 26.41 } @{ Value = 486.57 }, @{ Value = 26.41 }
) { ) {
$vmr.option.delay[$phys_out].set($value) $vmr.option.delay[$phys_out].set($value)
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.option.delay[$phys_out].get() | Should -Be $value $vmr.option.delay[$phys_out].get() | Should -Be $value
} }
@ -452,7 +452,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Value = 65535; Expected = 65535 } @{ Value = 65535; Expected = 65535 }
) { ) {
$vmr.vban.port = $value $vmr.vban.port = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.vban.port | Should -Be $expected $vmr.vban.port | Should -Be $expected
} }
@ -465,7 +465,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Value = 65535; Expected = 65535 } @{ Value = 65535; Expected = 65535 }
) { ) {
$vmr.vban.instream[$index].port = $value $vmr.vban.instream[$index].port = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.vban.instream[$index].port | Should -Be $expected $vmr.vban.instream[$index].port | Should -Be $expected
} }
@ -508,7 +508,7 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
@{ Value = 65535; Expected = 65535 } @{ Value = 65535; Expected = 65535 }
) { ) {
$vmr.vban.outstream[$index].port = $value $vmr.vban.outstream[$index].port = $value
$vmr.command.restart $vmr.command.restart()
Start-Sleep -Milliseconds 2000 Start-Sleep -Milliseconds 2000
$vmr.vban.outstream[$index].port | Should -Be $expected $vmr.vban.outstream[$index].port | Should -Be $expected
} }