-
Notifications
You must be signed in to change notification settings - Fork 985
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds code coverage to FormatControl (#12168)
Related #10773 ## Proposed changes - Adds code coverage to `FormatControl`. ## Customer Impact - None ## Regression? - No ## Risk - Minimal ## Test methodology - Unit tests ## Test environment(s) - 9.0.100-rc.1.24452.12 Co-authored-by: Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) <[email protected]>
- Loading branch information
1 parent
336362a
commit ea207b7
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...em.Windows.Forms.Design/tests/UnitTests/System/Windows/Forms/Design/FormatControlTests.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,44 @@ | ||
// 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 FormatControlTests : IDisposable | ||
{ | ||
private readonly FormatControl _formatControl = new(); | ||
public void Dispose() => _formatControl.Dispose(); | ||
|
||
[Fact] | ||
public void DefaultProperties_ShouldReturnExpected() | ||
{ | ||
_formatControl.Should().NotBeNull(); | ||
_formatControl.Should().BeOfType<FormatControl>(); | ||
_formatControl.Should().BeAssignableTo<Control>(); | ||
_formatControl.Dirty.Should().BeFalse(); | ||
_formatControl.FormatType.Should().BeEmpty(); | ||
_formatControl.NullValue.Should().BeNull(); | ||
} | ||
|
||
[Fact] | ||
public void SetsNullValueTextBoxEnabled_ShouldNotThrow() | ||
{ | ||
_formatControl.Invoking(f => f.NullValueTextBoxEnabled = false).Should().NotThrow(); | ||
} | ||
|
||
public static IEnumerable<object[]> TestData() | ||
{ | ||
yield return new object[] { null!, SR.BindingFormattingDialogFormatTypeNoFormatting }; | ||
yield return new object[] { "N1", SR.BindingFormattingDialogFormatTypeNumeric }; | ||
yield return new object[] { "d", SR.BindingFormattingDialogFormatTypeDateTime }; | ||
yield return new object[] { "E1", SR.BindingFormattingDialogFormatTypeScientific }; | ||
yield return new object[] { "CustomString", SR.BindingFormattingDialogFormatTypeCustom }; | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(TestData))] | ||
public void FormatTypeStringFromFormatString_ShouldReturnCorrectFormatType(string formatString, string formatTypeString) => FormatControl.FormatTypeStringFromFormatString(formatString).Should().Be(formatTypeString); | ||
|
||
[Fact] | ||
public void ResetFormattingInfo_ShouldNotThrow() => _formatControl.Invoking(f => f.ResetFormattingInfo()).Should().NotThrow(); | ||
} |