Skip to content

Commit

Permalink
Update RecordableCommands.cs (#11630)
Browse files Browse the repository at this point in the history
* Update RecordableCommands.cs

Add documentation for exceptions thrown by `UpdateModelValue` API

* add tests
  • Loading branch information
aparajit-pratap authored Apr 19, 2021
1 parent 44931b2 commit 103493f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DynamoCore/Models/RecordableCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,10 @@ protected override void SerializeCore(XmlElement element)
/// <summary>
/// A command used to update the value of a property on a model object.
/// </summary>
/// <exception cref="System.InvalidOperationException">This exception is
/// thrown if the node model is not found in the workspace.</exception>
/// /// <exception cref="System.ArgumentNullException">This exception is
/// thrown if the node model or list of node models passed is null or empty.</exception>
[DataContract]
public class UpdateModelValueCommand : ModelBasedRecordableCommand
{
Expand Down
21 changes: 21 additions & 0 deletions test/DynamoCoreTests/CoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,27 @@ public void CanCopyAndPasteAndUndoShowLabels()
Assert.IsFalse(addNode.DisplayLabels);
}

[Test]
[Category("")]
public void UpdateModelValue_MissingNode_ThrowsException()
{
var addNode = new DSFunction(CurrentDynamoModel.LibraryServices.GetFunctionDescriptor("+"));

CurrentDynamoModel.CurrentWorkspace.AddAndRegisterNode(addNode, false);
CurrentDynamoModel.CurrentWorkspace.RemoveAndDisposeNode(addNode);

var command = new DynCmd.UpdateModelValueCommand(Guid.Empty, addNode.GUID, "Code", "");
Assert.Throws<InvalidOperationException>(() => CurrentDynamoModel.ExecuteCommand(command));
}

[Test]
[Category("")]
public void UpdateModelValue_EmptyList_ThrowsException()
{
var command = new DynCmd.UpdateModelValueCommand(Guid.Empty, new Guid[] { }, "", "");
Assert.Throws<ArgumentNullException>(() => CurrentDynamoModel.ExecuteCommand(command));
}

[Test]
[Category("UnitTests")]
public void CanCopyAndPasteAndUndoInputState()
Expand Down

0 comments on commit 103493f

Please sign in to comment.