-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code coverage for ToolStripPanelControlCollection_XYComparer (#12711
) related #10453 Proposed changes Add unit tests for ToolStripPanelControlCollectionXYComparer.cs to test its methods
- Loading branch information
1 parent
ba481ce
commit a3da2c9
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...ts/System/Windows/Forms/ToolStripPanel.ToolStripPanelControlCollection.XYComparerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
using System.Drawing; | ||
|
||
namespace System.Windows.Forms.Tests; | ||
|
||
public class ToolStripPanel_ToolStripPanelControlCollection_XYComparerTests | ||
{ | ||
private readonly ToolStripPanel.ToolStripPanelControlCollection.XYComparer _comparer = new(); | ||
private readonly Control _control1 = new() { Bounds = new Rectangle(10, 20, 100, 100) }; | ||
private readonly Control _control2 = new() { Bounds = new Rectangle(10, 10, 100, 100) }; | ||
|
||
public void Dispose() | ||
{ | ||
_control1.Dispose(); | ||
_control2.Dispose(); | ||
} | ||
|
||
[WinFormsFact] | ||
public void Compare_FirstControlNull_ReturnsNegativeOne() => | ||
_comparer.Compare(null, _control1).Should().Be(-1); | ||
|
||
[WinFormsFact] | ||
public void Compare_SecondControlNull_ReturnsOne() => | ||
_comparer.Compare(_control1, null).Should().Be(1); | ||
|
||
[WinFormsFact] | ||
public void Compare_BothControlsNull_ReturnsZero() => | ||
_comparer.Compare(null, null).Should().Be(0); | ||
|
||
[WinFormsTheory] | ||
[InlineData(10, 10, 20, 10, -1)] | ||
[InlineData(10, 10, 10, 20, -1)] | ||
[InlineData(10, 20, 10, 10, 1)] | ||
[InlineData(20, 10, 10, 10, 1)] | ||
public void Compare_VariousBounds_ReturnsExpected(int x1, int y1, int x2, int y2, int expected) | ||
{ | ||
_control1.Bounds = new Rectangle(x1, y1, 100, 100); | ||
_control2.Bounds = new Rectangle(x2, y2, 100, 100); | ||
|
||
_comparer.Compare(_control1, _control2).Should().Be(expected); | ||
} | ||
} |