diff --git a/InteractiveAutomationToolkit/Components/RawValueMapping.cs b/InteractiveAutomationToolkit/Components/RawValueMapping.cs index 649d7ed..77666f8 100644 --- a/InteractiveAutomationToolkit/Components/RawValueMapping.cs +++ b/InteractiveAutomationToolkit/Components/RawValueMapping.cs @@ -13,7 +13,7 @@ internal class RawValueMapping public bool TryGetByRawValue(string rawValue, out T value) { - if (String.IsNullOrEmpty(rawValue)) + if (rawValue == null) { value = default; return false; @@ -118,7 +118,7 @@ private static string CleanDisplayValue(string displayValue) { if (String.IsNullOrEmpty(displayValue)) { - return "empty"; + return "\u200B"; } var sb = new StringBuilder(); diff --git a/InteractiveAutomationToolkitTests/ComponentTests.cs b/InteractiveAutomationToolkitTests/ComponentTests.cs index 0b5df15..742ae9c 100644 --- a/InteractiveAutomationToolkitTests/ComponentTests.cs +++ b/InteractiveAutomationToolkitTests/ComponentTests.cs @@ -58,6 +58,22 @@ public void DropDown_HandlePipeChar() Assert.AreEqual("--3", dropDown.BlockDefinition.InitialValue); } + [TestMethod] + public void DropDown_HandleEmptyOption() + { + DropDown dropDown = new DropDown(new[] { String.Empty, "|" }); + Assert.AreEqual(String.Empty, dropDown.Selected); + Assert.AreEqual("\u200B", dropDown.BlockDefinition.InitialValue); + + dropDown.Selected = "|"; + Assert.AreEqual("|", dropDown.Selected); + Assert.AreEqual("-", dropDown.BlockDefinition.InitialValue); + + dropDown.Selected = String.Empty; + Assert.AreEqual(String.Empty, dropDown.Selected); + Assert.AreEqual("\u200B", dropDown.BlockDefinition.InitialValue); + } + [TestMethod] public void GenericDropDown_HandlePipeChar() {