/// <summary>
        /// Construct a WatchViewModel from a Watch node
        /// </summary>
        private WatchViewModel GetWatchViewModel(Watch watch)
        {
            var inputVar = watch.IsPartiallyApplied
                ? watch.AstIdentifierForPreview.Name
                : watch.InPorts[0].Connectors[0].Start.Owner.AstIdentifierForPreview.Name;

            var core = ViewModel.Model.EngineController.LiveRunnerRuntimeCore;
            var watchHandler = ViewModel.WatchHandler;

            return watchHandler.GenerateWatchViewModelForData(
                watch.CachedValue,
                core,
                inputVar,
                false );
        }
        public void Defect_MAGN_3580()
        {
            // Create the initial code block node.
            var codeBlockNode0 = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Create the watch node.
            var watch = new Watch();
            var command = new DynCmd.CreateNodeCommand(
                watch, 0, 0, true, false);

            CurrentDynamoModel.ExecuteCommand(command);
            var workspace = CurrentDynamoModel.CurrentWorkspace;

            // Connect the two nodes
            ConnectorModel.Make(codeBlockNode0, watch, 0, 0);

            // Run
            Assert.DoesNotThrow(BeginRun);

            // Update the code block node
            UpdateCodeBlockNodeContent(codeBlockNode0, @"truuuue;");

            // Check
            Assert.AreEqual(1, codeBlockNode0.InPortData.Count);

            // Create the second code block node
            var codeBlockNode1 = CreateCodeBlockNode();
            UpdateCodeBlockNodeContent(codeBlockNode1, @"false;");

            // Connect the two code block nodes
            ConnectorModel.Make(codeBlockNode1, codeBlockNode0, 0, 0);

            // Run
            Assert.DoesNotThrow(BeginRun);

            UpdateCodeBlockNodeContent(codeBlockNode0, @"true;");

            // Check
            Assert.AreEqual(0, codeBlockNode0.InPortData.Count);

            // Run
            Assert.DoesNotThrow(BeginRun);

            // Delete the first code block node
            var nodes = new List<ModelBase> { codeBlockNode0 };
            CurrentDynamoModel.DeleteModelInternal(nodes);

            // Undo
            workspace.Undo();
        }