From 8954fa5ecfc9747fdcdc3a667488b5a5dfc4098d Mon Sep 17 00:00:00 2001 From: Thomas Nind <31306100+tznind@users.noreply.github.com> Date: Sun, 31 Dec 2023 12:45:20 +0000 Subject: [PATCH] Add constructor overload to SliderOption (#3101) * Add constructor overload to SliderOption * Adjust whitespace * Move tests to SliderOptionTests * Empty commit for CI --- Terminal.Gui/Views/Slider.cs | 19 +++++++++++++++++++ UnitTests/Views/SliderTests.cs | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/Terminal.Gui/Views/Slider.cs b/Terminal.Gui/Views/Slider.cs index 6a69f6c0eb..0280f5b307 100644 --- a/Terminal.Gui/Views/Slider.cs +++ b/Terminal.Gui/Views/Slider.cs @@ -48,6 +48,25 @@ public class SliderOption { /// public T Data { get; set; } + /// + /// Creates a new empty instance of the class. + /// + public SliderOption () + { + + } + + /// + /// Creates a new instance of the class with values for + /// each property. + /// + public SliderOption (string legend, Rune legendAbbr, T data) + { + Legend = legend; + LegendAbbr = legendAbbr; + Data = data; + } + /// /// To Raise the event from the Slider. /// diff --git a/UnitTests/Views/SliderTests.cs b/UnitTests/Views/SliderTests.cs index d593450bea..c3b4a628e3 100644 --- a/UnitTests/Views/SliderTests.cs +++ b/UnitTests/Views/SliderTests.cs @@ -9,6 +9,26 @@ namespace Terminal.Gui.ViewsTests; public class SliderOptionTests { + + + [Fact] + public void Slider_Option_Default_Constructor () + { + var o = new SliderOption (); + 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 ("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 () {