Skip to content

Cmdlet-binding tests, second slice (#173), plus two cmdlet fixes - #233

Merged
saveenr merged 2 commits into
masterfrom
cmdlet-binding-tests-slice2
Oct 1, 2026
Merged

saveenr merged 2 commits into
masterfrom
cmdlet-binding-tests-slice2

Conversation

@saveenr

@saveenr saveenr commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

Second slice of cmdlet-binding tests (#173), plus the two bugs they found.

Tests (VTest.PowerShell, 27 -> 73)

46 new tests that run scripts through the session's runspace, so PowerShell's binder resolves parameter sets, positions, mandatory parameters, switches and enums:

  • PageCmdletBindingTests: Get-VisioPage, New-VisioPage, Format-VisioPage, Remove-VisioPage.
  • ShapeCmdletBindingTests: Get-VisioShape, Select-VisioShape, Format-VisioShape, New-VisioHyperlink, Set-VisioCustomProperty, Connect-VisioShape (mandatory parameters only).
  • DocumentWindowCmdletBindingTests: Get-VisioDocument, Format-VisioWindow, and the type-driven parameter sets of Out-VisioApplication.
  • New CmdletScriptExtensions (RunInNewDocument, ExpectFailureInNewDocument, MessageOf) so each test builds everything in one script and returns plain values.

Bugs found and fixed

  • Format-VisioPage -Width / -Height always threw a COMException. PageCommands.SetFormatCells committed the page format cells to the Page object instead of its page sheet (SetPageSize already used the page sheet).
  • New-VisioHyperlink -NewWindow, -Default, -Invisible and -SortKey were accepted and ignored. HyperlinkHelper.Add had that code commented out, so the cells always stayed FALSE/unset. It now writes them to the shape sheet (sort key quoted so it is a valid formula).

I ran the four tests for these against the code without the fixes: all four failed. With the fixes they pass.

Deliberately not asserted

Get-VisioPage -ID uses the page index, not the page ID (#232). That is a decision for the maintainer, so no test pins either behavior.

Testing

Debug build, local Visio: VTest.PowerShell 73/73, VTest.Models 104/104, VTest.Scripting 43/43 (VTest, 108 tests, not touched).

Also

  • NuGet/CHANGELOG.md and VisioPowerShell/CHANGELOG.md [Unreleased]: Fixed entries.
  • docs/TESTING.md (counts and the new harness helpers), docs/futures/test-coverage-gaps.md and CLAUDE.md updated.

This PR also exercises the new master branch rule: auto-merge is enabled and should wait for Build (Debug) and Build (Release).

Refs #173, #232

🤖 Generated with Claude Code

TheSevenPens and others added 2 commits October 1, 2026 05:48
…flags

Format-VisioPage -Width and -Height always threw a COMException:
PageCommands.SetFormatCells committed the page format cells to the Page
object instead of its page sheet (SetPageSize already used the page sheet).

New-VisioHyperlink accepted -NewWindow, -Default, -Invisible and -SortKey and
ignored them: HyperlinkHelper.Add left those cells commented out, so they
always stayed FALSE or unset. It now writes them to the shape sheet (the
sort key quoted so it is a valid formula).

Found by the second slice of cmdlet-binding tests (#173). Each fix has tests
that fail without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 new tests in VTest.PowerShell covering parameter-set resolution, mandatory
parameters, switches, enums and pipeline binding for Get-VisioPage,
Get-VisioShape, Get-VisioDocument, Select-VisioShape, New-VisioPage,
Format-VisioPage, Remove-VisioPage, Format-VisioShape, New-VisioHyperlink,
Set-VisioCustomProperty, Connect-VisioShape, Format-VisioWindow and the
type-driven parameter sets of Out-VisioApplication.

Adds CmdletScriptExtensions (RunInNewDocument, ExpectFailureInNewDocument,
MessageOf) so each test runs one script in the runspace and returns plain
values. Updates the test counts, the TESTING.md harness notes, the coverage
gap list and CLAUDE.md. Get-VisioPage -ID's index-vs-ID question is filed as
#232 and deliberately not asserted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@saveenr
saveenr enabled auto-merge October 1, 2026 12:59
@saveenr
saveenr merged commit b56a4b4 into master Oct 1, 2026
2 checks passed
@TheSevenPens
TheSevenPens deleted the cmdlet-binding-tests-slice2 branch October 1, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants