Skip to content

Add PowerAccent.Core unit tests (geometry + positioning)#49104

Open
crutkas wants to merge 1 commit into
mainfrom
crutkas/poweraccent-core-tests
Open

Add PowerAccent.Core unit tests (geometry + positioning)#49104
crutkas wants to merge 1 commit into
mainfrom
crutkas/poweraccent-core-tests

Conversation

@crutkas

@crutkas crutkas commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

Adds PowerAccent.Core.UnitTests — new unit coverage for the Quick Accent (PowerAccent) core geometry and window-positioning logic. 62 tests, all passing.

This is the clean, tests-only portion of #46684, rebased onto current main and split so it can land without that PR's global dependency bump (Microsoft.Extensions 9→10, SemanticKernel, OpenAI, forced Directory.Build.props package references, etc.). Nothing outside PowerAccent is touched.

What's covered

  • RectTests / SizeTests / PointTests — constructors, implicit conversions, component-wise and scalar division, and divide-by-zero guards.
  • CalculationTestsCalculation.GetRawCoordinatesFromCaret and GetRawCoordinatesFromPosition: caret-relative placement, all nine anchor positions, horizontal/vertical clamping to screen edges, above/below flipping, multi-monitor origin offsets, and DPI scaling (1.0/1.5/2.0).

Production changes (test-coupled, minimal)

  • Rect.operator /(Rect, Rect) — the zero-divider guard previously checked only X and Y. Because the fields are double, a zero Width/Height divider silently produced Infinity instead of throwing. It now throws DivideByZeroException on any zero component (asserted by RectTests).
  • Size.operator /(Size, Size) — drops a duplicated clause in the zero guard (no behavior change).
  • PowerAccent.Core.csprojInternalsVisibleTo for the test assembly (Calculation is internal).

Why language tests from #46684 are omitted

The character/language mapping logic moved out of PowerAccent.Core into the new PowerAccent.Common project, which already has thorough, data-driven coverage in PowerAccent.Common.UnitTests (CharacterMappingsTests, LetterKeyTests). Porting the old LanguagesTests would have duplicated that against a deleted API, so it's intentionally left out.

Supersedes the PowerAccent portion of #46684.

Adds PowerAccent.Core.UnitTests covering the Rect/Size/Point value types
and the Calculation positioning math (caret-relative and anchored
placement, multi-monitor origin offsets, DPI scaling, and edge clamping).

Includes a small correctness fix in Rect.operator/(Rect,Rect): the zero
divider guard previously checked only X and Y, so a zero Width or Height
divider silently produced Infinity (the fields are double) instead of
throwing. It now throws DivideByZeroException on any zero component, which
the new RectTests assert. Size.operator/ drops a duplicated guard clause.
PowerAccent.Core exposes internals to the test assembly via
InternalsVisibleTo (Calculation is internal).

This is the clean, tests-only portion of #46684, without the global
dependency bump from that PR. Language/character coverage from #46684 is
intentionally omitted: that logic moved to PowerAccent.Common and is
already covered by PowerAccent.Common.UnitTests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the Product-Quick Accent Refers to the Quick Accent PowerToy label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Quick Accent Refers to the Quick Accent PowerToy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant