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 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"); }
public void CommandCanExecuteWithSelectionOfSrAndVdiOnRunningVms() { foreach (SrTuple srTuple in runningVmCanMigrateVdiData) { SR sr; VDI vdi; ResolveSrAndVdiNames(srTuple.SrName, srTuple.VdiName, out sr, out vdi); var cmd = new MigrateVirtualDiskCommand(mw, new[] { new SelectedItem(vdi) }); Assert.AreEqual(srTuple.ExpectedCanMigrate, cmd.CanExecute(), String.Format("VDI '{0}' on SR '{1}' can migrate", srTuple.VdiName, srTuple.SrName)); } }
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); }
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)); }
public void CheckContextMenuText() { var selectedVdi1 = new SelectedItem(new VDI()); var selectedVdi2 = new SelectedItem(new VDI()); var cmd = new MigrateVirtualDiskCommand(mw, new[] { selectedVdi1 }); Assert.AreEqual(Messages.MOVE_VDI_CONTEXT_MENU, cmd.ContextMenuText); cmd = new MigrateVirtualDiskCommand(mw, new[] { selectedVdi1, selectedVdi2 }); Assert.AreEqual(Messages.MAINWINDOW_MOVE_OBJECTS, cmd.ContextMenuText); }
internal static Command MoveMigrateCommand(IMainWindow mainWindow, SelectedItemCollection selection) { var cmd = new MigrateVirtualDiskCommand(mainWindow, selection); var con = selection.GetConnectionOfFirstItem(); if (cmd.CanExecute() && !Helpers.FeatureForbidden(con, Host.RestrictCrossPoolMigrate)) { return(cmd); } return(new MoveVirtualDiskCommand(mainWindow, selection)); }
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"); }
public void CheckContextMenuText() { MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, null as VDI); Assert.AreEqual(Messages.MOVE_VDI_CONTEXT_MENU, cmd.ContextMenuText); }