From ad6f07e0c5c848b109f0024ad45a7ba8297e0a17 Mon Sep 17 00:00:00 2001 From: "Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box)" Date: Fri, 13 Sep 2024 11:49:27 -0300 Subject: [PATCH] Adds code coverage for RichTextBoxActionList Related #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. ## Customer Impact - None or succinct description ## Regression? - No ## Risk - Minimal ## Test methodology - Unit tests ## Test environment(s) - 9.0.100-preview.7.24407.12 --- .../Design/RichTextBoxActionListTests.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/RichTextBoxActionListTests.cs diff --git a/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/RichTextBoxActionListTests.cs b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/RichTextBoxActionListTests.cs new file mode 100644 index 00000000000..63a66c6e25f --- /dev/null +++ b/src/System.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/RichTextBoxActionListTests.cs @@ -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 GetSortedActions_WithNull_ThrowsException() + { + Action action = () => new RichTextBoxActionList(null!); + action.Should().Throw(); + } + + [Fact] + public void GetSortedActions_WithDesigner_GetsCorrectItemsCount() + { + using RichTextBoxDesigner designer = new(); + using RichTextBox richTextBox = new(); + designer.Initialize(richTextBox); + var actionList = new RichTextBoxActionList(designer); + + actionList.GetSortedActionItems().Count.Should().Be(1); + } +}