Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions InteractiveAutomationToolkit/Components/RawValueMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class RawValueMapping<T>

public bool TryGetByRawValue(string rawValue, out T value)
{
if (String.IsNullOrEmpty(rawValue))
if (rawValue == null)
{
value = default;
return false;
Expand Down Expand Up @@ -118,7 +118,7 @@ private static string CleanDisplayValue(string displayValue)
{
if (String.IsNullOrEmpty(displayValue))
{
return "empty";
return "\u200B";
}
Comment on lines 118 to 122
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in 2075af1. Empty/null display values now map to a non-empty raw value ("-") so selections can be serialized and parsed back correctly, and I added a focused test (DropDown_HandleEmptyOption) to cover the behavior.


var sb = new StringBuilder();
Expand Down
16 changes: 16 additions & 0 deletions InteractiveAutomationToolkitTests/ComponentTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Loading