-
Notifications
You must be signed in to change notification settings - Fork 473
Remove exception swallowing and update tests to exhibit expected behaviour #2749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Maui.UnitTests/Services/PopupServiceTests.cs
Outdated
Show resolved
Hide resolved
…unityToolkit/Maui into feature/sl-improve-popup-unit-tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the old AddPopup helper to avoid swallowed exceptions and modernizes the unit tests to use short- and long-lived popup classes that correctly close themselves. Key changes include:
- Deleted the legacy internal
AddPopupmethod fromPopupService.shared.cs. - Replaced all uses of
MockSelfClosingPopup/MockPageViewModelin tests withShortLivedSelfClosingPopup/ShortLivedMockPageViewModel(and related long-lived variants). - Introduced new test popup types with configurable durations, added GC calls in open/close handlers, and updated the mock dispatcher to block for delays.
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Services/PopupService.shared.cs | Removed deprecated internal AddPopup method. |
| src/CommunityToolkit.Maui.UnitTests/Mocks/MockDispatcher.cs | Changed DispatchDelayed to use Thread.Sleep and return true. |
| src/CommunityToolkit.Maui.UnitTests/Layouts/StateContainerTests.cs | Switched to Assert.ThrowsAnyAsync for animation timeout tests. |
| src/CommunityToolkit.Maui.UnitTests/BaseHandlerTest.cs | Updated service registrations for the new popup/view-model types. |
Description of Change
This doesn't technically fix any bugs but it does fix some inconsistencies in our unit tests. You may notice there are some
Console.Writelinestatements in this PR. What I have observed on occasion is thatClosingis logged butClosedis not which makes me wonder if it is close to potentially reproducing #2703Linked Issues
PR Checklist
approved(bug) orChampioned(feature/proposal)mainat time of PRAdditional information