Add PowerAccent.Core unit tests (geometry + positioning)#49104
Open
crutkas wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainand split so it can land without that PR's global dependency bump (Microsoft.Extensions 9→10, SemanticKernel, OpenAI, forcedDirectory.Build.propspackage 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.CalculationTests—Calculation.GetRawCoordinatesFromCaretandGetRawCoordinatesFromPosition: 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 onlyXandY. Because the fields aredouble, a zeroWidth/Heightdivider silently producedInfinityinstead of throwing. It now throwsDivideByZeroExceptionon any zero component (asserted byRectTests).Size.operator /(Size, Size)— drops a duplicated clause in the zero guard (no behavior change).PowerAccent.Core.csproj—InternalsVisibleTofor the test assembly (Calculationisinternal).Why language tests from #46684 are omitted
The character/language mapping logic moved out of
PowerAccent.Coreinto the newPowerAccent.Commonproject, which already has thorough, data-driven coverage inPowerAccent.Common.UnitTests(CharacterMappingsTests,LetterKeyTests). Porting the oldLanguagesTestswould have duplicated that against a deleted API, so it's intentionally left out.Supersedes the PowerAccent portion of #46684.