Skip to content

Conversation

@John-Qiao
Copy link
Contributor

@John-Qiao John-Qiao commented Mar 7, 2025

Related #10773

Proposed changes

  • Add unit test ToolStripEditorManagerTests.cs for properties and methods of the ToolStripEditorManager.
Microsoft Reviewers: Open in CodeFlow

@John-Qiao John-Qiao requested a review from a team as a code owner March 7, 2025 11:03
@codecov
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 95.83333% with 5 lines in your changes missing coverage. Please review.

Project coverage is 61.73806%. Comparing base (eaaf38c) to head (0bd720c).
Report is 137 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13094         +/-   ##
===================================================
+ Coverage   61.28341%   61.73806%   +0.45464%     
===================================================
  Files           1541        1550          +9     
  Lines         158281      158740        +459     
  Branches       14743       14787         +44     
===================================================
+ Hits           97000       98003       +1003     
+ Misses         60584       60028        -556     
- Partials         697         709         +12     
Flag Coverage Δ
Debug 61.73806% <95.83333%> (-13.55401%) ⬇️
integration 10.72781% <ø> (-8.18343%) ⬇️
production 39.77066% <ø> (-35.52141%) ⬇️
test 95.67615% <95.83333%> (∅)
unit 37.21683% <ø> (-37.16254%) ⬇️

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@John-Qiao John-Qiao added the waiting-review This item is waiting on review by one or more members of team label Mar 10, 2025
@LeafShi1 LeafShi1 added waiting-author-feedback The team requires more information from the author and removed waiting-review This item is waiting on review by one or more members of team labels Mar 11, 2025
@Olina-Zhang Olina-Zhang removed the waiting-author-feedback The team requires more information from the author label Mar 26, 2025
@ricardobossan ricardobossan requested a review from Copilot March 26, 2025 22:39
Copy link
Contributor

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.

Pull Request Overview

This PR adds unit tests for ToolStripEditorManager to ensure its properties and methods behave as expected.

  • Added tests verifying constructor initialization, editor activation and deactivation, and property updates via a nested ToolStripEditorControl.

@ricardobossan ricardobossan added the waiting-author-feedback The team requires more information from the author label Mar 26, 2025
@Zheng-Li01 Zheng-Li01 removed the waiting-author-feedback The team requires more information from the author label Mar 27, 2025
Copy link
Member

@ricardobossan ricardobossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

ricardobossan
ricardobossan previously approved these changes Mar 27, 2025
[Fact]
public void ActivateEditor_ShouldNotAddNewEditor_WhenItemIsNull()
{
Action act = () => _editorManager.ActivateEditor(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActivateEditor method creates UI, this test should be a WinFormsFact.

_editorManager.TestAccessor().Dynamic._behaviorService = _behaviorService;
_editorManager.TestAccessor().Dynamic._currentItem = _toolStripItem;

Action act = () => _editorManager.ActivateEditor(_toolStripItem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActivateEditor method creates UI, this test should be a WinFormsFact.

_editorManager.TestAccessor().Dynamic._itemDesigner = new Mock<ToolStripItemDesigner>().Object;
_editorManager.TestAccessor().Dynamic._currentItem = new ToolStripButton();

_editorManager.ActivateEditor(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActivateEditor method creates UI, this test should be a WinFormsFact.

ToolStripItem currentItem = _editorManager.TestAccessor().Dynamic._currentItem;
currentItem.Should().Be(_toolStripItem);

ToolStripTemplateNode editorUI = _editorManager.TestAccessor().Dynamic._editorUI;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be WinFormsFact too.

[Fact]
public void OnEditorResize_ShouldInvalidateAndUpdateBounds()
{
_editorManager.TestAccessor().Dynamic._editor = _toolStripEditorControl!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be WinFormsFact too.

if (boundsProperty is not null)
{
boundsProperty.SetValue(_toolStripEditorControl, newBounds);
Rectangle? actualBounds = boundsProperty.GetValue(_toolStripEditorControl) as Rectangle?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be WinFormsFact too.

Rectangle newBounds = new(30, 40, 150, 250);
PropertyInfo? boundsProperty = _toolStripEditorControlType?.GetProperty("Bounds1");

if (boundsProperty is not null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please assert that this property is not null.

public void CloseManager_ShouldNotThrowException()
{
Action act = ToolStripEditorManager.CloseManager;
act.Should().NotThrow();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename act to action - this applies in several spots in this file.

@Tanya-Solyanik
Copy link
Contributor

Added some comments, overall looks good.

@Tanya-Solyanik Tanya-Solyanik added the waiting-author-feedback The team requires more information from the author label Mar 31, 2025
@ricardobossan ricardobossan dismissed their stale review March 31, 2025 23:34

New comments need to be addressed.

@Epica3055 Epica3055 force-pushed the Add-unit-tests-for-ToolStripEditorManager branch from 3265cde to 0bd720c Compare April 1, 2025 02:38
@Zheng-Li01
Copy link
Member

Resolved the FeedBacks with the new PR: #13218 due to John lack the permission handle this for now.

ricardobossan

This comment was marked as outdated.

@ricardobossan
Copy link
Member

Closing this as it's being handled in 13218 now.

Tanya-Solyanik pushed a commit that referenced this pull request Apr 8, 2025
Related #10773

Proposed changes
Add unit test file: ToolStripEditorManagerTests.cs for public methods & Properties of the ToolStripEditorManager.cs

Original PR: #13094
@github-actions github-actions bot locked and limited conversation to collaborators May 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

waiting-author-feedback The team requires more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants