From 103493f7fb6209df744a0e11ff51b71eec88d908 Mon Sep 17 00:00:00 2001 From: aparajit-pratap Date: Mon, 19 Apr 2021 18:43:09 -0400 Subject: [PATCH] Update RecordableCommands.cs (#11630) * Update RecordableCommands.cs Add documentation for exceptions thrown by `UpdateModelValue` API * add tests --- src/DynamoCore/Models/RecordableCommands.cs | 4 ++++ test/DynamoCoreTests/CoreTests.cs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/DynamoCore/Models/RecordableCommands.cs b/src/DynamoCore/Models/RecordableCommands.cs index 9459b57a47a..11acbb5189d 100644 --- a/src/DynamoCore/Models/RecordableCommands.cs +++ b/src/DynamoCore/Models/RecordableCommands.cs @@ -1715,6 +1715,10 @@ protected override void SerializeCore(XmlElement element) /// /// A command used to update the value of a property on a model object. /// + /// This exception is + /// thrown if the node model is not found in the workspace. + /// /// This exception is + /// thrown if the node model or list of node models passed is null or empty. [DataContract] public class UpdateModelValueCommand : ModelBasedRecordableCommand { diff --git a/test/DynamoCoreTests/CoreTests.cs b/test/DynamoCoreTests/CoreTests.cs index cd34153d081..981b772a298 100644 --- a/test/DynamoCoreTests/CoreTests.cs +++ b/test/DynamoCoreTests/CoreTests.cs @@ -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(() => CurrentDynamoModel.ExecuteCommand(command)); + } + + [Test] + [Category("")] + public void UpdateModelValue_EmptyList_ThrowsException() + { + var command = new DynCmd.UpdateModelValueCommand(Guid.Empty, new Guid[] { }, "", ""); + Assert.Throws(() => CurrentDynamoModel.ExecuteCommand(command)); + } + [Test] [Category("UnitTests")] public void CanCopyAndPasteAndUndoInputState()