public IEnumerator DeletableElementCanBeDeleted() { yield return(null); var node1 = m_NodeModel1.GetUI <Node>(graphView); var node2 = m_NodeModel2.GetUI <Node>(graphView); Assert.IsNotNull(node1); Assert.IsNotNull(node2); Assert.True(m_NodeModel1.IsDeletable()); Assert.False(m_NodeModel2.IsDeletable()); // We need to get the graphView in focus for the commands to be properly sent. graphView.Focus(); Assert.AreEqual(2, graphView.GraphElements.ToList().Count); CommandDispatcher.Dispatch(new SelectElementsCommand(SelectElementsCommand.SelectionMode.Replace, m_NodeModel1)); yield return(null); helpers.ExecuteCommand("Delete"); yield return(null); Assert.AreEqual(1, graphView.GraphElements.ToList().Count); // Node 2 is not deletable. // Selecting it and sending the Delete command should leave the node count unchanged. CommandDispatcher.Dispatch(new SelectElementsCommand(SelectElementsCommand.SelectionMode.Replace, m_NodeModel2)); yield return(null); helpers.ExecuteCommand("Delete"); yield return(null); Assert.AreEqual(1, graphView.GraphElements.ToList().Count); yield return(null); }