public void TestOnDeletionStarted() { //Arrange //This will subscribe our local method to the DeletionStarted event CurrentDynamoModel.DeletionStarted += CurrentDynamoModel_DeletionStarted; List <ModelBase> modelsToDelete = new List <ModelBase>(); Guid groupid = Guid.NewGuid(); CurrentDynamoModel.CurrentWorkspace.AddAnnotation("This is a test group", groupid); var annotations = CurrentDynamoModel.Workspaces.SelectMany(ws => ws.Annotations); foreach (var annotation in annotations) { modelsToDelete.Insert(0, annotation); } //Act var cancelEventArgs = new System.ComponentModel.CancelEventArgs(); CurrentDynamoModel.OnDeletionStarted(modelsToDelete, cancelEventArgs); //Inside the OnDeletionStarted there is a condition checking the Cancel state, then we need to set the value to true cancelEventArgs.Cancel = true; CurrentDynamoModel.OnDeletionStarted(modelsToDelete, cancelEventArgs); //Assert //This will validate that the local handler was executed and set the flag in true CurrentDynamoModel.DeletionStarted -= CurrentDynamoModel_DeletionStarted; Assert.IsTrue(deletionStarted); }