-
Notifications
You must be signed in to change notification settings - Fork 999
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for NotifyIconActionList (#12813)
Related #10773 Proposed changes Add unit test NotifyIconDesignerActionListTests.cs for public properties and methods of the NotifyIconDesignerActionList. Enable nullability in NotifyIconDesignerActionListTests.cs.
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...s.Design/tests/UnitTests/System/Windows/Forms/Design/NotifyIconDesignerActionListTests.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,53 @@ | ||
// 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.ComponentModel.Design; | ||
|
||
namespace System.Windows.Forms.Design.Tests; | ||
|
||
public sealed class NotifyIconActionListTests : IDisposable | ||
{ | ||
private readonly NotifyIconDesigner _designer; | ||
private readonly NotifyIcon _notifyIcon; | ||
private readonly NotifyIconActionList _actionList; | ||
|
||
public NotifyIconActionListTests() | ||
{ | ||
_designer = new(); | ||
_notifyIcon = new(); | ||
_designer.Initialize(_notifyIcon); | ||
_actionList = new(_designer); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_designer.Dispose(); | ||
_notifyIcon.Dispose(); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_ShouldInitializeActionList() => _actionList.Should().NotBeNull(); | ||
|
||
[Fact] | ||
public void ChooseIcon_ShouldNotBeNull() | ||
{ | ||
Action act = _actionList.ChooseIcon; | ||
act.Should().NotBeNull(); | ||
} | ||
|
||
[Fact] | ||
public void GetSortedActionItems_ShouldReturnCorrectItems() | ||
{ | ||
DesignerActionItemCollection items = _actionList.GetSortedActionItems(); | ||
|
||
items.Should().NotBeNull(); | ||
items.Count.Should().Be(1); | ||
items[0].Should().BeOfType<DesignerActionMethodItem>(); | ||
DesignerActionMethodItem methodItem = (DesignerActionMethodItem)items[0]; | ||
methodItem.MemberName.Should().Be(nameof(NotifyIconActionList.ChooseIcon)); | ||
methodItem.DisplayName.Should().Be(SR.ChooseIconDisplayName); | ||
methodItem.IncludeAsDesignerVerb.Should().BeTrue(); | ||
} | ||
} |