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 ToolStripContainerDesigner #12200

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Olina-Zhang
Copy link
Member

@Olina-Zhang Olina-Zhang commented Sep 23, 2024

Related #10773

Proposed changes

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

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 94.82759% with 3 lines in your changes missing coverage. Please review.

Project coverage is 75.44071%. Comparing base (99d42a9) to head (f90d22c).
Report is 43 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #12200         +/-   ##
===================================================
+ Coverage   75.26640%   75.44071%   +0.17430%     
===================================================
  Files           3086        3103         +17     
  Lines         633636      634322        +686     
  Branches       46839       46870         +31     
===================================================
+ Hits          476915      478537       +1622     
+ Misses        153316      152356        -960     
- Partials        3405        3429         +24     
Flag Coverage Δ
Debug 75.44071% <94.82759%> (+0.17430%) ⬆️
integration 17.97802% <ø> (-0.04330%) ⬇️
production 48.83175% <ø> (+0.25932%) ⬆️
test 97.02589% <94.82759%> (+0.00186%) ⬆️
unit 45.86519% <ø> (+0.25613%) ⬆️

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

@lonitra lonitra added the 📭 waiting-author-feedback The team requires more information from the author label Sep 26, 2024
@dotnet-policy-service dotnet-policy-service bot removed the 📭 waiting-author-feedback The team requires more information from the author label Sep 29, 2024
Comment on lines +95 to +108
public void Initialize_ShouldSetShadowProperties()
{
AssertShadowProperties("TopToolStripPanelVisible", _toolStripContainer.TopToolStripPanelVisible);
AssertShadowProperties("LeftToolStripPanelVisible", _toolStripContainer.LeftToolStripPanelVisible);
AssertShadowProperties("RightToolStripPanelVisible", _toolStripContainer.RightToolStripPanelVisible);
AssertShadowProperties("BottomToolStripPanelVisible", _toolStripContainer.BottomToolStripPanelVisible);
}

private void AssertShadowProperties(string propertyName, object expectedValue)
{
var property = typeof(ToolStripContainerDesigner).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
var actualValue = property?.GetValue(_designer);
actualValue.Should().Be(expectedValue);
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public void Initialize_ShouldSetShadowProperties()
{
AssertShadowProperties("TopToolStripPanelVisible", _toolStripContainer.TopToolStripPanelVisible);
AssertShadowProperties("LeftToolStripPanelVisible", _toolStripContainer.LeftToolStripPanelVisible);
AssertShadowProperties("RightToolStripPanelVisible", _toolStripContainer.RightToolStripPanelVisible);
AssertShadowProperties("BottomToolStripPanelVisible", _toolStripContainer.BottomToolStripPanelVisible);
}
private void AssertShadowProperties(string propertyName, object expectedValue)
{
var property = typeof(ToolStripContainerDesigner).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
var actualValue = property?.GetValue(_designer);
actualValue.Should().Be(expectedValue);
}
public void Initialize_ShouldSetShadowProperties()
{
AssertShadowProperties("TopToolStripPanelVisible", _toolStripContainer.TopToolStripPanelVisible);
AssertShadowProperties("LeftToolStripPanelVisible", _toolStripContainer.LeftToolStripPanelVisible);
AssertShadowProperties("RightToolStripPanelVisible", _toolStripContainer.RightToolStripPanelVisible);
AssertShadowProperties("BottomToolStripPanelVisible", _toolStripContainer.BottomToolStripPanelVisible);
void AssertShadowProperties(string propertyName, object expectedValue)
{
var property = typeof(ToolStripContainerDesigner).GetProperty(propertyName, BindingFlags.NonPublic | BindingFlags.Instance);
var actualValue = property?.GetValue(_designer);
actualValue.Should().Be(expectedValue);
}
}

@lonitra lonitra added the 📭 waiting-author-feedback The team requires more information from the author label Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

2 participants