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 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);
        }
        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 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 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);
 }
 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");
 }
Exemplo n.º 9
0
        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);
        }