diff --git a/CHANGELOG.md b/CHANGELOG.md index a2e8e9b..397655c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ Recorder.FileType changed from method to write-only property - Recorder.Prefix - Recorder.Eject() references 'Command.Eject' - Recorder.State +- Command.Reset() +- Command.Save($filepath) ### Changed diff --git a/README.md b/README.md index 9994d31..f56d825 100644 --- a/README.md +++ b/README.md @@ -428,6 +428,8 @@ The following methods are available: - HideVBANChat() - Restart() - Shutdown() +- Reset(): Reset all config +- Save($filepath): string - Load($filepath): string - RunMacrobuttons(): Launches the macrobuttons app - CloseMacrobuttons(): Closes the macrobuttons app @@ -437,7 +439,7 @@ example: ```powershell $vmr.command.show() -$vmr.command.lock = $true +$vmr.command.lock() $vmr.command.Load("path/to/filename.xml") diff --git a/lib/command.ps1 b/lib/command.ps1 index a8f412d..18926d1 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -1,6 +1,6 @@ class Special : IRemote { Special ([Object]$remote) : base ($remote) { - AddActionMembers -PARAMS @('restart', 'shutdown', 'show', 'lock') + AddActionMembers -PARAMS @('restart', 'shutdown', 'show', 'lock', 'reset') } [string] identifier () { @@ -36,6 +36,10 @@ class Special : IRemote { [void] Load ([string]$filename) { $this.Setter('load', $filename) } + + [void] Save ([string]$filename) { + $this.Setter('save', $filename) + } } function Make_Command([Object]$remote) { diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index 02f8e38..1e52c78 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -184,12 +184,6 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } - Context 'Command' { - It 'Should set command.lock' { - $vmr.command.lock = $value - } - } - Context 'Fx' -Skip:$ifNotPotato { Context 'Delay' { It 'Should set and get Fx.delay.on' { @@ -948,6 +942,51 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } } + + Context 'Command' { + It 'Should save, reset, then load config' -ForEach @( + @{ Gain = -27.1; Mode = 'composite'; Bit = 24; Port = 1044 } + ) { + $tmp = [System.IO.Path]::Combine([System.IO.Path]::GetTempPath(), "vmrconfig-$(New-Guid).xml") + try { + # set some values + $vmr.strip[$virt_in].gain = $gain + $vmr.bus[$phys_out].mode.set($mode) + $vmr.vban.outstream[$vban_outA].bit = $bit + $vmr.vban.port = $port + + # save config + $vmr.command.save($tmp) + Start-Sleep -Milliseconds 100 + Test-Path $tmp | Should -BeTrue + + # reset config + $vmr.command.reset() + Start-Sleep -Milliseconds 500 + + # verify default values + $vmr.strip[$virt_in].gain | Should -Be 0.0 + $vmr.bus[$phys_out].mode.get() | Should -Be 'normal' + $vmr.vban.outstream[$vban_outA].bit | Should -Be 16 + $vmr.vban.port | Should -Be 6980 + + # load config + $vmr.command.load($tmp) + Start-Sleep -Milliseconds 500 + + # verify values + $vmr.strip[$virt_in].gain | Should -Be $gain + $vmr.bus[$phys_out].mode.get() | Should -Be $mode + $vmr.vban.outstream[$vban_outA].bit | Should -Be $bit + $vmr.vban.port | Should -Be $port + } + finally { + if (Test-Path $tmp) { + Remove-Item $tmp -Force + } + } + } + } } Describe 'Action Tests' -Tag 'action' {