Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aparajit-pratap committed Dec 7, 2023
1 parent 76b04a4 commit 33c071b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 80 deletions.
49 changes: 0 additions & 49 deletions src/Libraries/CoreNodeModels/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,6 @@ public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode
}
}

[NodeName("Test Dropdown Node")]
[NodeCategory("TestUINodes")]
[NodeDescription("test dropdown node")]
[OutPortTypes("string")]
[IsDesignScriptCompatible]
public class TestDropdown : DSDropDownBase
{
public TestDropdown() : base("TestDropdown") { }


public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
AssociativeNode node;
if (SelectedIndex < 0 || SelectedIndex >= Items.Count)
{
node = AstFactory.BuildNullNode();
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), node) };
}
else
{
// get the selected items name
var stringNode = AstFactory.BuildStringNode((string)Items[SelectedIndex].Name);

// assign the selected name to an actual enumeration value
var assign = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), stringNode);

// return the enumeration value
return new List<AssociativeNode> { assign };
}
}

protected override SelectionState PopulateItemsCore(string currentSelection)
{
Items.Clear();

var symbols = new[] { "one", "two", "three" };


foreach (var symbol in symbols)
{

Items.Add(new DynamoDropDownItem(symbol, symbol));
}

return SelectionState.Restore;
}

}

public abstract class EnumBase<T> : DSDropDownBase
{
protected EnumBase() : base(typeof(T).ToString()) { }
Expand Down
62 changes: 31 additions & 31 deletions test/DynamoCoreWpfTests/NodeExecutionUITest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,48 +329,48 @@ public void TestSelectionNodeUpdate2()

}

// [Test]
// public void TestDropdownNodeUpdate()
// {
// var model = GetModel();
// var tdd = new TestDropdown
// {
// SelectedIndex = 0
// };
[Test]
public void TestDropdownNodeUpdate()
{
var model = GetModel();
var tdd = new TestDropdown
{
SelectedIndex = 0
};

// var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false);
// model.ExecuteCommand(command);
var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false);
model.ExecuteCommand(command);

// AssertPreviewValue(tdd.GUID.ToString(), "one");
AssertPreviewValue(tdd.GUID.ToString(), "one");

// tdd.SelectedIndex = 1;
// tdd.OnNodeModified();
tdd.SelectedIndex = 1;
tdd.OnNodeModified();

// AssertPreviewValue(tdd.GUID.ToString(), "two");
AssertPreviewValue(tdd.GUID.ToString(), "two");

// tdd.SelectedIndex = 2;
// tdd.OnNodeModified();
tdd.SelectedIndex = 2;
tdd.OnNodeModified();

// AssertPreviewValue(tdd.GUID.ToString(), "three");
AssertPreviewValue(tdd.GUID.ToString(), "three");

// }
}

// [Test, Category("Failure")]
// public void TestDropdownNodeUpdate1()
// {
// var model = GetModel();
// var tdd = new TestDropdown();
[Test]
public void TestDropdownNodeUpdate1()
{
var model = GetModel();
var tdd = new TestDropdown();

// var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false);
// model.ExecuteCommand(command);
var command = new DynamoModel.CreateNodeCommand(tdd, 0, 0, true, false);
model.ExecuteCommand(command);

// AssertPreviewValue(tdd.GUID.ToString(), null);
AssertPreviewValue(tdd.GUID.ToString(), null);

// tdd.SelectedIndex = 1;
// tdd.OnNodeModified();
tdd.SelectedIndex = 1;
tdd.OnNodeModified();

// // fails here!
// AssertPreviewValue(tdd.GUID.ToString(), "two");
// }
// fails here!
AssertPreviewValue(tdd.GUID.ToString(), "two");
}
}
}

0 comments on commit 33c071b

Please sign in to comment.