Skip to content

Commit

Permalink
Add constructor overload to SliderOption<T> (gui-cs#3101)
Browse files Browse the repository at this point in the history
* Add constructor overload to SliderOption

* Adjust whitespace

* Move tests to SliderOptionTests

* Empty commit for CI
  • Loading branch information
tznind authored Dec 31, 2023
1 parent 55bf533 commit 8954fa5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Terminal.Gui/Views/Slider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ public class SliderOption<T> {
/// </summary>
public T Data { get; set; }

/// <summary>
/// Creates a new empty instance of the <see cref="SliderOption{T}"/> class.
/// </summary>
public SliderOption ()
{

}

/// <summary>
/// Creates a new instance of the <see cref="SliderOption{T}"/> class with values for
/// each property.
/// </summary>
public SliderOption (string legend, Rune legendAbbr, T data)
{
Legend = legend;
LegendAbbr = legendAbbr;
Data = data;
}

/// <summary>
/// To Raise the <see cref="Set"/> event from the Slider.
/// </summary>
Expand Down
20 changes: 20 additions & 0 deletions UnitTests/Views/SliderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@
namespace Terminal.Gui.ViewsTests;

public class SliderOptionTests {


[Fact]
public void Slider_Option_Default_Constructor ()
{
var o = new SliderOption<int> ();
Assert.Null (o.Legend);
Assert.Equal (default, o.LegendAbbr);
Assert.Equal (default, o.Data);
}

[Fact]
public void Slider_Option_Values_Constructor ()
{
var o = new SliderOption<int> ("1 thousand", new Rune ('y'), 1000);
Assert.Equal ("1 thousand", o.Legend);
Assert.Equal (new Rune ('y'), o.LegendAbbr);
Assert.Equal (1000, o.Data);
}

[Fact]
public void OnSet_Should_Raise_SetEvent ()
{
Expand Down

0 comments on commit 8954fa5

Please sign in to comment.