コード例 #1
0
 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));
     }
 }
コード例 #2
0
 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");
 }
コード例 #3
0
        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();
        }
コード例 #4
0
 public void CommandCannotExecuteNullVdi()
 {
     MigrateVirtualDiskCommand cmd = new MigrateVirtualDiskCommand(mw, null as VDI);
     Assert.IsFalse(cmd.CanExecute(), "Null vdi");
 }
コード例 #5
0
 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);
 }
コード例 #6
0
 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");
 }
コード例 #7
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);
        }