-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for ContextMenuStripGroupCollection (#11952)
Related #10773 Add unit test ContextMenuStripGroupCollectionTests.cs for public properties and method of the ContextMenuStripGroupCollection. Enable nullability in ContextMenuStripGroupCollection.
- Loading branch information
1 parent
abbccaa
commit 14acefa
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...esign/tests/UnitTests/System/Windows/Forms/Design/ContextMenuStripGroupCollectionTests.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,55 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#nullable enable | ||
|
||
namespace System.Windows.Forms.Design.Tests; | ||
|
||
public class ContextMenuStripGroupCollectionTests | ||
{ | ||
[Fact] | ||
public void Indexer_ShouldCreateNewGroupIfKeyDoesNotExist() | ||
{ | ||
ContextMenuStripGroupCollection collection = new(); | ||
|
||
ContextMenuStripGroup group = collection["newKey"]; | ||
|
||
group.Should().NotBeNull(); | ||
group.Should().BeOfType<ContextMenuStripGroup>(); | ||
collection.ContainsKey("newKey").Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void ContainsKey_ShouldReturnFalseIfKeyDoesNotExist() | ||
{ | ||
ContextMenuStripGroupCollection collection = new(); | ||
|
||
bool containsKey = collection.ContainsKey("nonExistentKey"); | ||
|
||
containsKey.Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void Indexer_ShouldReturnSameGroupForSameKey() | ||
{ | ||
ContextMenuStripGroupCollection collection = new(); | ||
|
||
ContextMenuStripGroup group1 = collection["newKey"]; | ||
ContextMenuStripGroup group2 = collection["newKey"]; | ||
|
||
group1.Should().BeSameAs(group2); | ||
} | ||
|
||
[Fact] | ||
public void Indexer_ShouldReturnDifferentGroupsForDifferentKeys() | ||
{ | ||
ContextMenuStripGroupCollection collection = new(); | ||
|
||
ContextMenuStripGroup group1 = collection["key1"]; | ||
ContextMenuStripGroup group2 = collection["key2"]; | ||
|
||
group1.Should().NotBeSameAs(group2); | ||
collection.ContainsKey("key1").Should().BeTrue(); | ||
collection.ContainsKey("key2").Should().BeTrue(); | ||
} | ||
} |