public void DeleteSnapshotPureAsyncActionTest()
 {
     mockProxy.Setup(x => x.vm_destroy(It.IsAny<string>(), "testvm")).Returns(new Response<string>(""));
     VM vm = GetVM();
     SetupPureAsyncAction(vm);
     vm.power_state = vm_power_state.Halted;
     var action = new VMSnapshotDeleteAction(vm);
     action.Completed += action_Completed;
     action.RunAsync();
     _autoResetEvent.WaitOne();
     Assert.True(action.Succeeded);
     mockProxy.VerifyAll();
 }
        private List<AsyncAction> getDestroyVDIAction(VDI vdi, List<VM> deletedVMSnapshots)
        {
            List<AsyncAction> actions = new List<AsyncAction>();

            // Destroy the entire snapshot if it exists.  Else destroy disk
            if (vdi.is_a_snapshot && vdi.GetVMs().Count >= 1)
            {
                foreach (VM vm in vdi.GetVMs())
                {
                    if (!vm.is_a_snapshot || deletedVMSnapshots.Contains(vm))
                        continue;

                    AsyncAction action = new VMSnapshotDeleteAction(vm);
                    actions.Add(action);
                    deletedVMSnapshots.Add(vm);
                }
            }
            else
            {
                SR sr = vdi.Connection.Resolve(vdi.SR);
                if (sr == null)
                {
                    // Nothing we can do here, but this should have been caught in the getcantexecutereason method and prompted
                    return actions;
                }
                DestroyDiskAction a = new DestroyDiskAction(vdi);
                a.AllowRunningVMDelete = AllowRunningVMDelete;
                actions.Add(a);
            }

            return actions;
        }