public void VerifyThrowsArgumentNullException()
 {
     foreach (TestData data in TestCasesArgumentNullException)
     {
         Assert.Throws<ArgumentNullException>(() => { var filter = new CrossPoolMigrateCanMigrateFilter(data.Item1, data.Item2, WizardMode.Migrate); });
     }
 }
        public static bool CanExecute(VM vm, Host preselectedHost)
        {
            bool failureFound = false;

            if (preselectedHost != null)
            {
                failureFound = new CrossPoolMigrateCanMigrateFilter(preselectedHost, new List<VM> { vm }).FailureFound;
            }

            return !failureFound &&
                   vm.allowed_operations != null &&
                   vm.allowed_operations.Contains(vm_operations.migrate_send) &&
                   !Helpers.CrossPoolMigrationRestrictedWithWlb(vm.Connection) &&
                   vm.SRs.ToList().All(sr=> sr != null && !sr.HBALunPerVDI) &&
                   (preselectedHost == null || vm.Connection.Resolve(vm.resident_on) != preselectedHost); //Not the same as the pre-selected host
        }
 public void VerifyMigrationNotAllowedCurrentServer()
 {
     foreach (TestData data in TestCasesMigrationNotAllowedCurrentServer)
     {
         var filter = new CrossPoolMigrateCanMigrateFilter(data.Item1, data.Item2, WizardMode.Migrate);
         Assert.True(filter.FailureFound, "Expected to find failure");
         Assert.IsNullOrEmpty(filter.Reason, "Did not expect failure reason");
     }
 }
        protected override bool CanExecute(VM vm)
        {
            bool failureFound = false;

            if(preSelectedHost != null)
            {
                failureFound = new CrossPoolMigrateCanMigrateFilter(preSelectedHost, new List<VM> { vm }).FailureFound;
            }

            return !failureFound &&
                   vm.allowed_operations != null &&
                   vm.allowed_operations.Contains(vm_operations.migrate_send) &&
                   !Helpers.WlbEnabledAndConfigured(vm.Connection) &&
                   vm.SRs.ToList().All(sr=> sr != null && !sr.HBALunPerVDI) &&
                   vm.Connection.Resolve(vm.resident_on) != preSelectedHost; //Not the same as the pre-selected host
        }
        public void VerifyMigrationNotAllowed()
        {
            Init();
            foreach (TestData data in TestCasesMigrationNotAllowedIfAssertion)
            {
                Assert.That(data.vms.Count, Is.AtLeast(1), "VM count needs to be at least 1 for this test");

                //fakeVM will say a failure is found if vm ref is set to Failure.INTERNAL_ERROR
                data.vms[0].opaque_ref = Failure.INTERNAL_ERROR;
                Assert.That(data.vms[0].opaque_ref, Is.EqualTo(Failure.INTERNAL_ERROR));

                CrossPoolMigrateCanMigrateFilter cmd = new CrossPoolMigrateCanMigrateFilter(data.ixo, data.vms);
                Assert.That(cmd.FailureFound, Is.True, "failure found");
                Assert.That(cmd.Reason, Is.EqualTo(Failure.INTERNAL_ERROR), "failure message");

            }

        }
 public void VerifyNullListArgsThrow()
 {
     bool failureFound = new CrossPoolMigrateCanMigrateFilter(singlePool, null).FailureFound;
 }
 private void VerifyMigrationAllowed(IXenObject ixo, List<VM> vms)
 {
     CrossPoolMigrateCanMigrateFilter cmd = new CrossPoolMigrateCanMigrateFilter(ixo, vms);
     Assert.That(cmd.FailureFound, Is.False, "failure found");
     Assert.That(cmd.Reason, Is.Null, "failure message");
 }