Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Nora-Zhou01
Copy link
Member

@Nora-Zhou01 Nora-Zhou01 commented Feb 26, 2025

Related #10773

Proposed changes

  • Add unit test ToolStripAdornerWindowServiceTests.cs for public properties and method of the ToolStripAdornerWindowService
  • Enable nullability in ToolStripAdornerWindowServiceTests.cs
Microsoft Reviewers: Open in CodeFlow

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 91.53846% with 11 lines in your changes missing coverage. Please review.

Project coverage is 76.06432%. Comparing base (e91e3bc) to head (02c7043).
Report is 325 commits behind head on main.

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     
Flag Coverage Δ
Debug 76.06432% <91.53846%> (+0.30977%) ⬆️
integration 18.01386% <ø> (-0.16092%) ⬇️
production 50.02463% <ø> (+0.70708%) ⬆️
test 96.93532% <91.53846%> (-0.10975%) ⬇️
unit 47.47903% <ø> (+0.94733%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link

@Copilot Copilot AI left a 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.

Comment on lines +65 to +73

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);
Copy link
Preview

Copilot AI Feb 27, 2025

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.

Suggested change
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.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
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.

1 participant