-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add unit tests for ToolStripEditorManager #13094
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 ToolStripEditorManager #13094
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Show resolved
Hide resolved
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Outdated
Show resolved
Hide resolved
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Show resolved
Hide resolved
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 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.
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Show resolved
Hide resolved
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Show resolved
Hide resolved
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Outdated
Show resolved
Hide resolved
...dows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/ToolStripEditorManagerTests.cs
Show resolved
Hide resolved
ricardobossan
left a comment
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.
Thank you!
| [Fact] | ||
| public void ActivateEditor_ShouldNotAddNewEditor_WhenItemIsNull() | ||
| { | ||
| Action act = () => _editorManager.ActivateEditor(null); |
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.
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); |
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.
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); |
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.
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; |
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.
This one should be WinFormsFact too.
| [Fact] | ||
| public void OnEditorResize_ShouldInvalidateAndUpdateBounds() | ||
| { | ||
| _editorManager.TestAccessor().Dynamic._editor = _toolStripEditorControl!; |
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.
This one should be WinFormsFact too.
| if (boundsProperty is not null) | ||
| { | ||
| boundsProperty.SetValue(_toolStripEditorControl, newBounds); | ||
| Rectangle? actualBounds = boundsProperty.GetValue(_toolStripEditorControl) as Rectangle?; |
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.
This one should be WinFormsFact too.
| Rectangle newBounds = new(30, 40, 150, 250); | ||
| PropertyInfo? boundsProperty = _toolStripEditorControlType?.GetProperty("Bounds1"); | ||
|
|
||
| if (boundsProperty is not null) |
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.
Please assert that this property is not null.
| public void CloseManager_ShouldNotThrowException() | ||
| { | ||
| Action act = ToolStripEditorManager.CloseManager; | ||
| act.Should().NotThrow(); |
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.
Please rename act to action - this applies in several spots in this file.
|
Added some comments, overall looks good. |
3265cde to
0bd720c
Compare
|
Resolved the FeedBacks with the new PR: #13218 due to John lack the permission handle this for now. |
|
Closing this as it's being handled in 13218 now. |
Related #10773
Proposed changes
Microsoft Reviewers: Open in CodeFlow