public void CommandCanExecuteWithSelectionOfSrAndVdiOnRunningVms() { foreach (SrTuple srTuple in runningVmCanMigrateVdiData) { SR sr; VDI vdi; ResolveSrAndVdiNames(srTuple.SrName, srTuple.VdiName, out sr, out vdi); MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, vdi); Assert.AreEqual(srTuple.ExpectedCanMigrate, cmd.CanExecute(), String.Format("VDI '{0}' on SR '{1}' can migrate", srTuple.VdiName, srTuple.SrName)); } }
public void TestMultipleSelectionsAllValid() { List<SelectedItem> selection = CreateVdiSelection(runningVmCanMigrateVdiData, t=>t.ExpectedCanMigrate); Assert.IsNotEmpty(selection); MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, selection); Assert.IsTrue(cmd.CanExecute(), "All valid selection can migrate"); }
public void CommandCanExecuteWithSelectionOfSrAndVdiOnShutdownVms() { ShutdownAllVMs(); foreach (SrTuple srTuple in runningVmCanMigrateVdiData) { SR sr; VDI vdi; ResolveSrAndVdiNames(srTuple.SrName, srTuple.VdiName, out sr, out vdi); MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, vdi); Assert.IsFalse(cmd.CanExecute(), String.Format("VDI '{0}' on SR '{1}' can migrate", srTuple.VdiName, srTuple.SrName)); } StartAllVMs(); }
public void CommandCannotExecuteNullVdi() { MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, null as VDI); Assert.IsFalse(cmd.CanExecute(), "Null vdi"); }
private void ExecuteCommandCheckingReason(string expectedReason, VDI vdi) { MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, new List<SelectedItem> { new SelectedItem(vdi) }); Dictionary<SelectedItem, string> reasons = cmd.GetCantExecuteReasons(); Assert.IsNotEmpty(reasons, "Reasons found for " + vdi.name_label); Assert.IsFalse(cmd.CanExecute(), "Command can execute for " + vdi.name_label); Assert.AreEqual(expectedReason, reasons.First().Value, "Reason as expected for " + vdi.name_label); }
public void TestMultipleSelectionsMixed() { List<SelectedItem> selection = CreateVdiSelection(runningVmCanMigrateVdiData, t=>true); Assert.IsNotEmpty(selection); MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, selection); Assert.IsFalse(cmd.CanExecute(), "Mixture in/valid selection can migrate"); }
internal static Command MoveMigrateCommand(IMainWindow mainWindow, IEnumerable<SelectedItem> selection) { var cmd = new MigrateVirtualDiskCommand(mainWindow, selection); if (cmd.CanExecute()) return cmd; return new MoveVirtualDiskCommand(mainWindow, selection); }