public bool VerifyLunPerVdiBehaviour(bool IsLunPerVdi) { Mock<VM> vm = ObjectFactory.BuiltObject<VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock<SR> sr = ObjectManager.NewXenObject<SR>(id); Mock<Host> targetHost = ObjectManager.NewXenObject<Host>(id); vm.Setup(v => v.SRs).Returns(new List<SR> {sr.Object}); vm.Setup(v => v.allowed_operations).Returns(new List<vm_operations> {vm_operations.migrate_send}); sr.Setup(s => s.HBALunPerVDI).Returns(IsLunPerVdi); IMainWindow mw = new MockMainWindow(); CrossPoolMigrateCommand cmd = new CrossPoolMigrateCommand(mw, new List<SelectedItem> { new SelectedItem(vm.Object)}, targetHost.Object); return cmd.CanExecute(); }
public bool VerifyLunPerVdiBehaviour(bool IsLunPerVdi) { Mock <VM> vm = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock <SR> sr = ObjectManager.NewXenObject <SR>(id); vm.Setup(v => v.SRs).Returns(new List <SR> { sr.Object }); vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> { vm_operations.migrate_send }); sr.Setup(s => s.HBALunPerVDI).Returns(IsLunPerVdi); IMainWindow mw = new MockMainWindow(); var cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> { new SelectedItem(vm.Object) }, null); return(cmd.CanExecute()); }
public bool IntrapoolWlbEnabledBehaviour(bool WlbEnabled) { Mock <VM> vm = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock <Host> targetHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id); ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(targetHost.Object); vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> { vm_operations.migrate_send }); Mock <Pool> pool = ObjectManager.NewXenObject <Pool>(id); pool.Setup(p => p.wlb_enabled).Returns(WlbEnabled); pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true IMainWindow mw = new MockMainWindow(); var cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> { new SelectedItem(vm.Object) }, null); bool canExecute = cmd.CanExecute(); pool.Verify(p => p.wlb_enabled, Times.AtLeastOnce()); return(canExecute); }
public bool CrossPoolWlbEnabledBehaviour(bool WlbEnabledVM, bool WlbEnabledTarget) { //First connection Mock <VM> vm = ObjectFactory.BuiltObject <VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock <Host> master = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id); ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(master.Object); vm.Setup(v => v.allowed_operations).Returns(new List <vm_operations> { vm_operations.migrate_send }); Mock <Pool> pool = ObjectManager.NewXenObject <Pool>(id); pool.Setup(p => p.wlb_enabled).Returns(WlbEnabledVM); pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true //Second connection Mock <Host> targetHost = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.TampaHost, id2); Mock <Pool> targetPool = ObjectManager.NewXenObject <Pool>(id2); ObjectManager.MockConnectionFor(id2).Setup(c => c.Resolve(It.IsAny <XenRef <Host> >())).Returns(targetHost.Object); targetPool.Setup(p => p.wlb_enabled).Returns(WlbEnabledTarget); targetPool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true //Command IMainWindow mw = new MockMainWindow(); var cmd = new CrossPoolMigrateCommand(mw, new List <SelectedItem> { new SelectedItem(vm.Object) }, null); bool canExecute = cmd.CanExecute(); //As the command is launching the wizard it should only need to //check the VMs are on Wlb as the target can be changed in the wizard anyhow pool.Verify(p => p.wlb_enabled, Times.AtLeastOnce()); targetPool.Verify(tp => tp.wlb_enabled, Times.Never()); return(canExecute); }
public bool IntrapoolWlbEnabledBehaviour(bool WlbEnabled) { Mock<VM> vm = ObjectFactory.BuiltObject<VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock<Host> targetHost = ObjectFactory.BuiltObject<Host>(ObjectBuilderType.TampaHost, id); Mock<Host> preselectedHost = ObjectFactory.BuiltObject<Host>(ObjectBuilderType.TampaHost, id); ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny<XenRef<Host>>())).Returns(targetHost.Object); vm.Setup(v => v.allowed_operations).Returns(new List<vm_operations> { vm_operations.migrate_send }); Mock<Pool> pool = ObjectManager.NewXenObject<Pool>(id); pool.Setup(p => p.wlb_enabled).Returns(WlbEnabled); pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true IMainWindow mw = new MockMainWindow(); CrossPoolMigrateCommand cmd = new CrossPoolMigrateCommand(mw, new List<SelectedItem> { new SelectedItem(vm.Object) }, preselectedHost.Object); bool canExecute = cmd.CanExecute(); pool.Verify(p=>p.wlb_enabled, Times.AtLeastOnce()); return canExecute; }
public bool CrossPoolWlbEnabledBehaviour(bool WlbEnabledVM, bool WlbEnabledTarget) { //First connection Mock<VM> vm = ObjectFactory.BuiltObject<VM>(ObjectBuilderType.VmWithHomeServerHost, id); Mock<Host> master = ObjectFactory.BuiltObject<Host>(ObjectBuilderType.TampaHost, id); ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny<XenRef<Host>>())).Returns(master.Object); vm.Setup(v => v.allowed_operations).Returns(new List<vm_operations> { vm_operations.migrate_send }); Mock<Pool> pool = ObjectManager.NewXenObject<Pool>(id); pool.Setup(p => p.wlb_enabled).Returns(WlbEnabledVM); pool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true //Second connection Mock<Host> targetHost = ObjectFactory.BuiltObject<Host>(ObjectBuilderType.TampaHost, id2); Mock<Pool> targetPool = ObjectManager.NewXenObject<Pool>(id2); ObjectManager.MockConnectionFor(id2).Setup(c => c.Resolve(It.IsAny<XenRef<Host>>())).Returns(targetHost.Object); targetPool.Setup(p => p.wlb_enabled).Returns(WlbEnabledTarget); targetPool.Setup(p => p.wlb_url).Returns("wlburl"); //Configured == true //Command IMainWindow mw = new MockMainWindow(); CrossPoolMigrateCommand cmd = new CrossPoolMigrateCommand(mw, new List<SelectedItem> { new SelectedItem(vm.Object) }, targetHost.Object); bool canExecute = cmd.CanExecute(); //As the command is launching the wizard it should only need to //check the VMs are on Wlb as the target can be changed in the wizard anyhow pool.Verify(p => p.wlb_enabled, Times.AtLeastOnce()); targetPool.Verify(tp => tp.wlb_enabled, Times.Never()); return canExecute; }