-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add unit tests for ToolStripAdornerWindowService #13029
base: main
Are you sure you want to change the base?
Add unit tests for ToolStripAdornerWindowService #13029
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13029 +/- ##
===================================================
+ Coverage 75.75455% 76.06432% +0.30977%
===================================================
Files 3159 3254 +95
Lines 635942 643320 +7378
Branches 46987 47395 +408
===================================================
+ Hits 481755 489337 +7582
+ Misses 150726 150425 -301
- Partials 3461 3558 +97
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
PR Overview
This pull request adds unit tests for the ToolStripAdornerWindowService to validate its public properties and methods along with enabling nullability in the tests.
- Introduces multiple tests covering graphics, coordinate translation, and resource disposal.
- Provides STA-thread execution for tests that interact with UI components.
Reviewed Changes
File | Description |
---|---|
src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripAdornerWindowServiceTests.cs | Contains new unit tests for verifying ToolStripAdornerWindowService behavior and proper handling of designer overlays and graphics. |
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
|
||
public ToolStripAdornerWindowServiceTests() => (_behaviorServiceWrapper, _service) = Initialize(); | ||
|
||
private (BehaviorServiceWrapper, ToolStripAdornerWindowService) Initialize() | ||
{ | ||
BehaviorServiceWrapper behaviorServiceWrapper = new(); | ||
using Control control = new(); | ||
var service = new ToolStripAdornerWindowService(behaviorServiceWrapper.ServiceProviderMock.Object, control); | ||
return (behaviorServiceWrapper, service); |
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.
The test creates a Control in a using statement, causing it to be disposed immediately after the tool strip service is initialized. Consider instantiating the control without a using block to ensure it remains available for the lifetime of the service during testing.
public ToolStripAdornerWindowServiceTests() => (_behaviorServiceWrapper, _service) = Initialize(); | |
private (BehaviorServiceWrapper, ToolStripAdornerWindowService) Initialize() | |
{ | |
BehaviorServiceWrapper behaviorServiceWrapper = new(); | |
using Control control = new(); | |
var service = new ToolStripAdornerWindowService(behaviorServiceWrapper.ServiceProviderMock.Object, control); | |
return (behaviorServiceWrapper, service); | |
private readonly Control _control; | |
public ToolStripAdornerWindowServiceTests() => (_behaviorServiceWrapper, _service, _control) = Initialize(); | |
private (BehaviorServiceWrapper, ToolStripAdornerWindowService, Control) Initialize() | |
{ | |
BehaviorServiceWrapper behaviorServiceWrapper = new(); | |
Control control = new(); | |
var service = new ToolStripAdornerWindowService(behaviorServiceWrapper.ServiceProviderMock.Object, control); | |
return (behaviorServiceWrapper, service, control); |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Related #10773
Proposed changes
Microsoft Reviewers: Open in CodeFlow