Skip to content

Commit

Permalink
Add code coverage for RichTextBoxActionList (#12131)
Browse files Browse the repository at this point in the history
Add code coverage to RichTextBoxActionList

Related to #10773

## Proposed changes

- Adds code coverage for `RichTextBoxActionList`
- Coverage for the `EditLines()` method could not be added. The
dependent method `EditorServiceContext.EditValue(_designer, Component!,
"Lines")` is static and could not be mocked, and the dialog that opens
during its execution requires manual intervention to close.


Co-authored-by: Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) <[email protected]>
  • Loading branch information
ricardobossan and Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) authored Sep 18, 2024
1 parent f54f3e9 commit 0c96068
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 sealed class RichTextBoxActionListTests
{
[Fact]
public void Ctor_WithNull_ThrowsException()
{
Action action = () => new RichTextBoxActionList(null!);
action.Should().Throw<NullReferenceException>();
}

[Fact]
public void GetSortedActions_WithDesigner_GetsCorrectItemsCount()
{
using RichTextBoxDesigner designer = new();
using RichTextBox richTextBox = new();
designer.Initialize(richTextBox);
RichTextBoxActionList actionList = new(designer);

actionList.GetSortedActionItems().Count.Should().Be(1);
}
}

0 comments on commit 0c96068

Please sign in to comment.