Skip to content

Commit

Permalink
Add unit tests for NumericUpDownAcceleration (dotnet#12705)
Browse files Browse the repository at this point in the history
Related dotnet#10453

Proposed changes
Add unit tests for NumericUpDownAcceleration.cs to test its properties & methods
Enable nullability in NumericUpDownAccelerationTests.cs
  • Loading branch information
Syareel-Sukeri authored and Ricardo Bossan (BEYONDSOFT CONSULTING INC) (from Dev Box) committed Jan 9, 2025
1 parent 1f11886 commit a5462cd
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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;

public class NumericUpDownAccelerationTests
{
[WinFormsFact]
public void NumericUpDownAcceleration_SecondsProperty_WorksAsExpected()
{
NumericUpDownAcceleration acceleration = new(5, 1.0m);

acceleration.Seconds.Should().Be(5);

acceleration.Seconds = 10;
acceleration.Seconds.Should().Be(10);

Action act = () => acceleration.Seconds = -1;
act.Should().Throw<ArgumentOutOfRangeException>();
}

[WinFormsFact]
public void NumericUpDownAcceleration_IncrementProperty_WorksAsExpected()
{
NumericUpDownAcceleration acceleration = new(5, 1.0m);

acceleration.Increment.Should().Be(1.0m);

acceleration.Increment = 2.0m;
acceleration.Increment.Should().Be(2.0m);

Action act = () => acceleration.Increment = -1.0m;
act.Should().Throw<ArgumentOutOfRangeException>();
}
}

0 comments on commit a5462cd

Please sign in to comment.