diff --git a/.gitignore b/.gitignore
index e0c4b20..cbf4d10 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,8 @@ packages/*
**/.svn
_git2_*
**/StyleCop.Cache
-*.DotSettings.user
\ No newline at end of file
+*.DotSettings.user
+# Build output nuget packages
+*.nupkg
+# Stray Windows-style path artifacts created by local build tools
+**/C:/
diff --git a/InteractiveAutomationToolkit/Components/CheckBoxList.cs b/InteractiveAutomationToolkit/Components/CheckBoxList.cs
index 0ae9dd1..e07eedd 100644
--- a/InteractiveAutomationToolkit/Components/CheckBoxList.cs
+++ b/InteractiveAutomationToolkit/Components/CheckBoxList.cs
@@ -161,6 +161,18 @@ public void RemoveOption(string option)
}
}
+ ///
+ /// When option is null.
+ public bool ContainsOption(string option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return options.ContainsKey(option);
+ }
+
///
/// When option is null.
/// When the option does not exist.
diff --git a/InteractiveAutomationToolkit/Components/DropDown.cs b/InteractiveAutomationToolkit/Components/DropDown.cs
index b42ec61..26baf47 100644
--- a/InteractiveAutomationToolkit/Components/DropDown.cs
+++ b/InteractiveAutomationToolkit/Components/DropDown.cs
@@ -151,6 +151,36 @@ public void RemoveOption(string option)
}
}
+ ///
+ /// When option is null.
+ public bool ContainsOption(string option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return options.Contains(option);
+ }
+
+ ///
+ /// When option is null.
+ public bool TrySelectOption(string option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ if (ContainsOption(option))
+ {
+ Selected = option;
+ return true;
+ }
+
+ return false;
+ }
+
///
protected internal override void LoadResult(IUIResults uiResults, ILogger logger = null)
{
diff --git a/InteractiveAutomationToolkit/Components/Generics/GenericCheckBoxList.cs b/InteractiveAutomationToolkit/Components/Generics/GenericCheckBoxList.cs
index 8892f78..362141a 100644
--- a/InteractiveAutomationToolkit/Components/Generics/GenericCheckBoxList.cs
+++ b/InteractiveAutomationToolkit/Components/Generics/GenericCheckBoxList.cs
@@ -144,6 +144,23 @@ public void AddOption(T value)
AddOption(new Option(value));
}
+ ///
+ public bool ContainsOption(Option option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return checkBoxListOptions.ContainsKey(option);
+ }
+
+ ///
+ public bool ContainsOption(T value)
+ {
+ return checkBoxListOptions.Keys.Any(x => Object.Equals(x.Value, value));
+ }
+
///
/// When option is null.
/// When the option does not exist.
diff --git a/InteractiveAutomationToolkit/Components/Generics/GenericDropDown.cs b/InteractiveAutomationToolkit/Components/Generics/GenericDropDown.cs
index 124d2aa..bda2e59 100644
--- a/InteractiveAutomationToolkit/Components/Generics/GenericDropDown.cs
+++ b/InteractiveAutomationToolkit/Components/Generics/GenericDropDown.cs
@@ -232,6 +232,54 @@ public void RemoveOption(T value)
}
}
+ ///
+ /// When option is null.
+ public bool ContainsOption(Option option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return dropDownOptions.Contains(option);
+ }
+
+ ///
+ public bool ContainsOption(T value)
+ {
+ return dropDownOptions.Any(x => Object.Equals(x.Value, value));
+ }
+
+ ///
+ public bool TrySelectOption(T value)
+ {
+ if (ContainsOption(value))
+ {
+ Selected = value;
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// When option is null.
+ public bool TrySelectOption(Option option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ if (ContainsOption(option))
+ {
+ SelectedOption = option;
+ return true;
+ }
+
+ return false;
+ }
+
///
protected internal override void LoadResult(IUIResults uiResults, ILogger logger = null)
{
diff --git a/InteractiveAutomationToolkit/Components/Generics/GenericRadioButtonList.cs b/InteractiveAutomationToolkit/Components/Generics/GenericRadioButtonList.cs
index d76f114..edd472f 100644
--- a/InteractiveAutomationToolkit/Components/Generics/GenericRadioButtonList.cs
+++ b/InteractiveAutomationToolkit/Components/Generics/GenericRadioButtonList.cs
@@ -239,6 +239,53 @@ public virtual void SetOptions(IEnumerable options)
SetOptions(options.Select(x => new Option(x)));
}
+ ///
+ public bool ContainsOption(Option option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return radioButtonListOptions.Contains(option);
+ }
+
+ ///
+ public bool ContainsOption(T value)
+ {
+ return radioButtonListOptions.Any(x => Object.Equals(x.Value, value));
+ }
+
+ ///
+ public bool TrySelectOption(T value)
+ {
+ if (ContainsOption(value))
+ {
+ Selected = value;
+ return true;
+ }
+
+ return false;
+ }
+
+ ///
+ /// When option is null.
+ public bool TrySelectOption(Option option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ if (ContainsOption(option))
+ {
+ SelectedOption = option;
+ return true;
+ }
+
+ return false;
+ }
+
///
protected internal override void LoadResult(IUIResults uiResults, ILogger logger = null)
{
diff --git a/InteractiveAutomationToolkit/Components/Interfaces/IDropDown.cs b/InteractiveAutomationToolkit/Components/Interfaces/IDropDown.cs
index 039212d..66c0f4c 100644
--- a/InteractiveAutomationToolkit/Components/Interfaces/IDropDown.cs
+++ b/InteractiveAutomationToolkit/Components/Interfaces/IDropDown.cs
@@ -9,6 +9,13 @@ public interface IDropDown : IOptionWidget
/// Gets or sets the currently selected option as a string.
///
string Selected { get; set; }
+
+ ///
+ /// Attempts to select the specified option. If the option does not exist in the collection, the selection remains unchanged.
+ ///
+ /// The option to select.
+ /// true if the option was found and selected; otherwise, false.
+ bool TrySelectOption(string option);
}
///
@@ -26,6 +33,20 @@ public interface IDropDown : IOptionWidget
/// Gets or sets the value of the currently selected option.
///
T Selected { get; set; }
+
+ ///
+ /// Attempts to select the option with the specified value. If no matching option exists, the selection remains unchanged.
+ ///
+ /// The value of the option to select.
+ /// true if a matching option was found and selected; otherwise, false.
+ bool TrySelectOption(T value);
+
+ ///
+ /// Attempts to select the specified option. If the option does not exist in the collection, the selection remains unchanged.
+ ///
+ /// The option to select.
+ /// true if the option was found and selected; otherwise, false.
+ bool TrySelectOption(Option option);
}
}
\ No newline at end of file
diff --git a/InteractiveAutomationToolkit/Components/Interfaces/IOptionWidget.cs b/InteractiveAutomationToolkit/Components/Interfaces/IOptionWidget.cs
index b3e2b80..0605ec9 100644
--- a/InteractiveAutomationToolkit/Components/Interfaces/IOptionWidget.cs
+++ b/InteractiveAutomationToolkit/Components/Interfaces/IOptionWidget.cs
@@ -29,6 +29,13 @@ public interface IOptionWidget
///
/// The option to remove.
void RemoveOption(string option);
+
+ ///
+ /// Determines whether the specified option exists in the collection.
+ ///
+ /// The name of the option to locate. Cannot be null.
+ /// true if the option exists in the collection; otherwise, false.
+ bool ContainsOption(string option);
}
///
@@ -82,6 +89,20 @@ public interface IOptionWidget
///
/// The value to remove.
void RemoveOption(T value);
+
+ ///
+ /// Determines whether the specified option is present in the collection.
+ ///
+ /// The option to locate in the collection. Cannot be null.
+ /// true if the specified option exists in the collection; otherwise, false.
+ bool ContainsOption(Option option);
+
+ ///
+ /// Determines whether the specified option exists in the collection.
+ ///
+ /// The option value to locate in the collection.
+ /// true if the specified option is found; otherwise, false.
+ bool ContainsOption(T value);
}
}
\ No newline at end of file
diff --git a/InteractiveAutomationToolkit/Components/Interfaces/IRadioButtonList.cs b/InteractiveAutomationToolkit/Components/Interfaces/IRadioButtonList.cs
index def0ffb..07865f0 100644
--- a/InteractiveAutomationToolkit/Components/Interfaces/IRadioButtonList.cs
+++ b/InteractiveAutomationToolkit/Components/Interfaces/IRadioButtonList.cs
@@ -9,6 +9,13 @@ public interface IRadioButtonList : IOptionWidget
/// Currently selected option.
///
string Selected { get; set; }
+
+ ///
+ /// Attempts to select the specified option. If the option does not exist in the collection, the selection remains unchanged.
+ ///
+ /// The option to select.
+ /// true if the option was found and selected; otherwise, false.
+ bool TrySelectOption(string option);
}
///
@@ -26,5 +33,19 @@ public interface IRadioButtonList : IOptionWidget
/// Value of the currently selected option.
///
T Selected { get; set; }
+
+ ///
+ /// Attempts to select the option with the specified value. If no matching option exists, the selection remains unchanged.
+ ///
+ /// The value of the option to select.
+ /// true if a matching option was found and selected; otherwise, false.
+ bool TrySelectOption(T value);
+
+ ///
+ /// Attempts to select the specified option. If the option does not exist in the collection, the selection remains unchanged.
+ ///
+ /// The option to select.
+ /// true if the option was found and selected; otherwise, false.
+ bool TrySelectOption(Option option);
}
}
diff --git a/InteractiveAutomationToolkit/Components/RadioButtonList.cs b/InteractiveAutomationToolkit/Components/RadioButtonList.cs
index 723b9a1..c46a253 100644
--- a/InteractiveAutomationToolkit/Components/RadioButtonList.cs
+++ b/InteractiveAutomationToolkit/Components/RadioButtonList.cs
@@ -146,6 +146,35 @@ public void SetOptions(IEnumerable options)
}
}
+ ///
+ public bool ContainsOption(string option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ return options.Contains(option);
+ }
+
+ ///
+ /// When option is null.
+ public bool TrySelectOption(string option)
+ {
+ if (option == null)
+ {
+ throw new ArgumentNullException(nameof(option));
+ }
+
+ if (ContainsOption(option))
+ {
+ Selected = option;
+ return true;
+ }
+
+ return false;
+ }
+
///
protected internal override void LoadResult(IUIResults uiResults, ILogger logger = null)
{
diff --git a/InteractiveAutomationToolkitTests/CheckBoxListTests.cs b/InteractiveAutomationToolkitTests/CheckBoxListTests.cs
new file mode 100644
index 0000000..10bdbbd
--- /dev/null
+++ b/InteractiveAutomationToolkitTests/CheckBoxListTests.cs
@@ -0,0 +1,25 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Skyline.DataMiner.Utils.InteractiveAutomationScript;
+
+namespace InteractiveAutomationToolkitTests
+{
+ [TestClass]
+ public class CheckBoxListTests
+ {
+ [TestMethod]
+ public void ContainsOption_ExistingOption_ReturnsTrue()
+ {
+ var checkBoxList = new CheckBoxList(new[] { "a", "b", "c" });
+
+ Assert.IsTrue(checkBoxList.ContainsOption("b"));
+ }
+
+ [TestMethod]
+ public void ContainsOption_MissingOption_ReturnsFalse()
+ {
+ var checkBoxList = new CheckBoxList(new[] { "a", "b", "c" });
+
+ Assert.IsFalse(checkBoxList.ContainsOption("z"));
+ }
+ }
+}
diff --git a/InteractiveAutomationToolkitTests/DropDownTests.cs b/InteractiveAutomationToolkitTests/DropDownTests.cs
new file mode 100644
index 0000000..06303a8
--- /dev/null
+++ b/InteractiveAutomationToolkitTests/DropDownTests.cs
@@ -0,0 +1,47 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Skyline.DataMiner.Utils.InteractiveAutomationScript;
+
+namespace InteractiveAutomationToolkitTests
+{
+ [TestClass]
+ public class DropDownTests
+ {
+ [TestMethod]
+ public void ContainsOption_ExistingOption_ReturnsTrue()
+ {
+ var dropDown = new DropDown(new[] { "a", "b", "c" });
+
+ Assert.IsTrue(dropDown.ContainsOption("b"));
+ }
+
+ [TestMethod]
+ public void ContainsOption_MissingOption_ReturnsFalse()
+ {
+ var dropDown = new DropDown(new[] { "a", "b", "c" });
+
+ Assert.IsFalse(dropDown.ContainsOption("z"));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var dropDown = new DropDown(new[] { "a", "b", "c" }, "a");
+
+ bool result = dropDown.TrySelectOption("c");
+
+ Assert.IsTrue(result);
+ Assert.AreEqual("c", dropDown.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var dropDown = new DropDown(new[] { "a", "b", "c" }, "a");
+
+ bool result = dropDown.TrySelectOption("z");
+
+ Assert.IsFalse(result);
+ Assert.AreEqual("a", dropDown.Selected);
+ }
+ }
+}
diff --git a/InteractiveAutomationToolkitTests/GenericCheckBoxListTests.cs b/InteractiveAutomationToolkitTests/GenericCheckBoxListTests.cs
index bc34c29..4099ef1 100644
--- a/InteractiveAutomationToolkitTests/GenericCheckBoxListTests.cs
+++ b/InteractiveAutomationToolkitTests/GenericCheckBoxListTests.cs
@@ -454,5 +454,46 @@ public void EmptyOption_Test2()
Assert.IsTrue(checkboxlist.CheckedOptions.Single().IsEmpty);
}
+
+ [TestMethod]
+ public void ContainsOption_ByValue_ExistingOption_ReturnsTrue()
+ {
+ var checkboxlist = new CheckBoxList(new[] { 1, 2, 3 });
+
+ Assert.IsTrue(checkboxlist.ContainsOption(2));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByValue_MissingOption_ReturnsFalse()
+ {
+ var checkboxlist = new CheckBoxList(new[] { 1, 2, 3 });
+
+ Assert.IsFalse(checkboxlist.ContainsOption(99));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_ExistingOption_ReturnsTrue()
+ {
+ var option = new Option("two", 2);
+ var checkboxlist = new CheckBoxList(new[] { new Option("one", 1), option });
+
+ Assert.IsTrue(checkboxlist.ContainsOption(option));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_MissingOption_ReturnsFalse()
+ {
+ var checkboxlist = new CheckBoxList(new[] { new Option("one", 1) });
+
+ Assert.IsFalse(checkboxlist.ContainsOption(new Option("two", 2)));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_NullOption_ThrowsArgumentNullException()
+ {
+ var checkboxlist = new CheckBoxList(new[] { 1, 2 });
+
+ Assert.ThrowsExactly(() => checkboxlist.ContainsOption((Option)null));
+ }
}
}
diff --git a/InteractiveAutomationToolkitTests/GenericDropDownTests.cs b/InteractiveAutomationToolkitTests/GenericDropDownTests.cs
index 9b29392..29f6cec 100644
--- a/InteractiveAutomationToolkitTests/GenericDropDownTests.cs
+++ b/InteractiveAutomationToolkitTests/GenericDropDownTests.cs
@@ -210,5 +210,101 @@ public void EmptyOption_Test2()
Assert.IsNull(dropDown.Selected);
Assert.IsTrue(dropDown.SelectedOption.IsEmpty);
}
+
+ [TestMethod]
+ public void ContainsOption_ByValue_ExistingOption_ReturnsTrue()
+ {
+ var dropDown = new DropDown(new[] { 1, 2, 3 });
+
+ Assert.IsTrue(dropDown.ContainsOption(2));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByValue_MissingOption_ReturnsFalse()
+ {
+ var dropDown = new DropDown(new[] { 1, 2, 3 });
+
+ Assert.IsFalse(dropDown.ContainsOption(99));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_ExistingOption_ReturnsTrue()
+ {
+ var option = new Option("two", 2);
+ var dropDown = new DropDown(new[] { new Option("one", 1), option });
+
+ Assert.IsTrue(dropDown.ContainsOption(option));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_MissingOption_ReturnsFalse()
+ {
+ var dropDown = new DropDown(new[] { new Option("one", 1) });
+
+ Assert.IsFalse(dropDown.ContainsOption(new Option("two", 2)));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByValue_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var dropDown = new DropDown(new[] { 1, 2, 3 }, 1);
+
+ bool result = dropDown.TrySelectOption(3);
+
+ Assert.IsTrue(result);
+ Assert.AreEqual(3, dropDown.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByValue_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var dropDown = new DropDown(new[] { 1, 2, 3 }, 1);
+
+ bool result = dropDown.TrySelectOption(99);
+
+ Assert.IsFalse(result);
+ Assert.AreEqual(1, dropDown.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var option1 = new Option("one", 1);
+ var option2 = new Option("two", 2);
+ var dropDown = new DropDown(new[] { option1, option2 }, option1);
+
+ bool result = dropDown.TrySelectOption(option2);
+
+ Assert.IsTrue(result);
+ Assert.AreEqual(option2, dropDown.SelectedOption);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var option1 = new Option("one", 1);
+ var dropDown = new DropDown(new[] { option1 }, option1);
+
+ bool result = dropDown.TrySelectOption(new Option("missing", 99));
+
+ Assert.IsFalse(result);
+ Assert.AreEqual(option1, dropDown.SelectedOption);
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_NullOption_ThrowsArgumentNullException()
+ {
+ var dropDown = new DropDown(new[] { 1, 2 });
+
+ Assert.ThrowsExactly(() => dropDown.ContainsOption((Option)null));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_NullOption_ThrowsArgumentNullException()
+ {
+ var dropDown = new DropDown(new[] { 1, 2 });
+
+ Assert.ThrowsExactly(() => dropDown.TrySelectOption((Option)null));
+ }
}
}
diff --git a/InteractiveAutomationToolkitTests/GenericRadioButtonListTests.cs b/InteractiveAutomationToolkitTests/GenericRadioButtonListTests.cs
index 575feec..c6a5ee0 100644
--- a/InteractiveAutomationToolkitTests/GenericRadioButtonListTests.cs
+++ b/InteractiveAutomationToolkitTests/GenericRadioButtonListTests.cs
@@ -240,5 +240,101 @@ public void EmptyOption_Test2()
Assert.IsNull(radioButtonList.Selected);
Assert.IsTrue(radioButtonList.SelectedOption.IsEmpty);
}
+
+ [TestMethod]
+ public void ContainsOption_ByValue_ExistingOption_ReturnsTrue()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2, 3 });
+
+ Assert.IsTrue(radioButtonList.ContainsOption(2));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByValue_MissingOption_ReturnsFalse()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2, 3 });
+
+ Assert.IsFalse(radioButtonList.ContainsOption(99));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_ExistingOption_ReturnsTrue()
+ {
+ var option = new Option("two", 2);
+ var radioButtonList = new RadioButtonList(new[] { new Option("one", 1), option });
+
+ Assert.IsTrue(radioButtonList.ContainsOption(option));
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_MissingOption_ReturnsFalse()
+ {
+ var radioButtonList = new RadioButtonList(new[] { new Option("one", 1) });
+
+ Assert.IsFalse(radioButtonList.ContainsOption(new Option("two", 2)));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByValue_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2, 3 }, 1);
+
+ bool result = radioButtonList.TrySelectOption(3);
+
+ Assert.IsTrue(result);
+ Assert.AreEqual(3, radioButtonList.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByValue_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2, 3 }, 1);
+
+ bool result = radioButtonList.TrySelectOption(99);
+
+ Assert.IsFalse(result);
+ Assert.AreEqual(1, radioButtonList.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var option1 = new Option("one", 1);
+ var option2 = new Option("two", 2);
+ var radioButtonList = new RadioButtonList(new[] { option1, option2 }, option1);
+
+ bool result = radioButtonList.TrySelectOption(option2);
+
+ Assert.IsTrue(result);
+ Assert.AreEqual(option2, radioButtonList.SelectedOption);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var option1 = new Option("one", 1);
+ var radioButtonList = new RadioButtonList(new[] { option1 }, option1);
+
+ bool result = radioButtonList.TrySelectOption(new Option("missing", 99));
+
+ Assert.IsFalse(result);
+ Assert.AreEqual(option1, radioButtonList.SelectedOption);
+ }
+
+ [TestMethod]
+ public void ContainsOption_ByOption_NullOption_ThrowsArgumentNullException()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2 });
+
+ Assert.ThrowsExactly(() => radioButtonList.ContainsOption((Option)null));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ByOption_NullOption_ThrowsArgumentNullException()
+ {
+ var radioButtonList = new RadioButtonList(new[] { 1, 2 });
+
+ Assert.ThrowsExactly(() => radioButtonList.TrySelectOption((Option)null));
+ }
}
}
diff --git a/InteractiveAutomationToolkitTests/RadioButtonListTests.cs b/InteractiveAutomationToolkitTests/RadioButtonListTests.cs
index b733ce1..40fdefa 100644
--- a/InteractiveAutomationToolkitTests/RadioButtonListTests.cs
+++ b/InteractiveAutomationToolkitTests/RadioButtonListTests.cs
@@ -50,5 +50,43 @@ public void SetOptionsTest_OverwriteSelected()
Assert.IsNull(radioButtonList.Selected);
}
+
+ [TestMethod]
+ public void ContainsOption_ExistingOption_ReturnsTrue()
+ {
+ var radioButtonList = new RadioButtonList(new[] { "a", "b", "c" });
+
+ Assert.IsTrue(radioButtonList.ContainsOption("b"));
+ }
+
+ [TestMethod]
+ public void ContainsOption_MissingOption_ReturnsFalse()
+ {
+ var radioButtonList = new RadioButtonList(new[] { "a", "b", "c" });
+
+ Assert.IsFalse(radioButtonList.ContainsOption("z"));
+ }
+
+ [TestMethod]
+ public void TrySelectOption_ExistingOption_SelectsAndReturnsTrue()
+ {
+ var radioButtonList = new RadioButtonList(new[] { "a", "b", "c" }, "a");
+
+ bool result = radioButtonList.TrySelectOption("c");
+
+ Assert.IsTrue(result);
+ Assert.AreEqual("c", radioButtonList.Selected);
+ }
+
+ [TestMethod]
+ public void TrySelectOption_MissingOption_ReturnsFalseAndKeepsSelection()
+ {
+ var radioButtonList = new RadioButtonList(new[] { "a", "b", "c" }, "a");
+
+ bool result = radioButtonList.TrySelectOption("z");
+
+ Assert.IsFalse(result);
+ Assert.AreEqual("a", radioButtonList.Selected);
+ }
}
}
\ No newline at end of file