Beispiel #1
0
        private static Mock <Host> GetAMockHost(string productVersion, string buildNumber, List <Pool_patch> applied_patches = null)
        {
            var id = System.Guid.NewGuid().ToString();

            MockObjectManager mom = new MockObjectManager();

            mom.CreateNewConnection(id);

            Mock <Host>   master    = mom.NewXenObject <Host>(id);
            Mock <Pool>   pool      = mom.NewXenObject <Pool>(id);
            XenRef <Host> masterRef = new XenRef <Host>("master-ref");

            pool.Setup(p => p.master).Returns(masterRef);

            mom.MockCacheFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Pool> >())).Returns(pool.Object);

            mom.MockConnectionFor(id).Setup(c => c.Resolve(masterRef)).Returns(master.Object);
            mom.MockConnectionFor(id).Setup(c => c.Cache.Hosts).Returns(new Host[] { master.Object });
            mom.MockConnectionFor(id).Setup(c => c.Cache.Pools).Returns(new Pool[] { pool.Object });

            master.Setup(h => h.software_version).Returns(new Dictionary <string, string>());
            master.Setup(h => h.ProductVersion()).Returns(productVersion);
            master.Setup(h => h.AppliedPatches()).Returns(applied_patches ?? new List <Pool_patch>());
            master.Setup(h => h.BuildNumberRaw()).Returns(buildNumber);
            master.Setup(h => h.uuid).Returns(id);
            return(master);
        }
Beispiel #2
0
        private AsyncAction deleteVifAction(string id)
        {
            Mock <VM> vm = ObjectManager.NewXenObject <VM>(id);

            vm.Setup(v => v.power_state).Returns(vm_power_state.Running);
            ObjectManager.MockConnectionFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <VM> >())).Returns(vm.Object);
            return(new DeleteVIFAction(ObjectManager.NewXenObject <VIF>(id).Object));
        }
Beispiel #3
0
        private void SetupMocks(List <XenServerPatch> xenServerPatches, List <XenServerVersion> xenServerVersions)
        {
            Mock <Host>   master    = mom.NewXenObject <Host>(id);
            Mock <Pool>   pool      = mom.NewXenObject <Pool>(id);
            XenRef <Host> masterRef = new XenRef <Host>("ref");

            pool.Setup(p => p.master).Returns(masterRef);
            pool.Setup(p => p.other_config).Returns(new Dictionary <string, string>());
            mom.MockCacheFor(id).Setup(c => c.Resolve(It.IsAny <XenRef <Pool> >())).Returns(pool.Object);
            mom.MockConnectionFor(id).Setup(c => c.Resolve(masterRef)).Returns(master.Object);
            mom.MockConnectionFor(id).Setup(c => c.IsConnected).Returns(true);
            master.Setup(h => h.software_version).Returns(new Dictionary <string, string>());
            master.Setup(h => h.ProductVersion()).Returns(ServerVersion);
            master.Setup(h => h.AppliedPatches()).Returns(GenerateMockPoolPatches(xenServerPatches));

            //Currently build number will be referenced first so if it's present hook it up
            string buildNumber = xenServerVersions.First(v => v.Version.ToString() == ServerVersion).BuildNumber;

            master.Setup(h => h.BuildNumberRaw()).Returns(buildNumber);
        }
        private static Mock<Host> GetAMockHost(string productVersion, string buildNumber, List<Pool_patch> applied_patches = null)
        {
            var id = System.Guid.NewGuid().ToString();

            MockObjectManager mom = new MockObjectManager();

            mom.CreateNewConnection(id);

            Mock<Host> master = mom.NewXenObject<Host>(id);
            Mock<Pool> pool = mom.NewXenObject<Pool>(id);
            XenRef<Host> masterRef = new XenRef<Host>("master-ref");
            pool.Setup(p => p.master).Returns(masterRef);

            mom.MockCacheFor(id).Setup(c => c.Resolve(It.IsAny<XenRef<Pool>>())).Returns(pool.Object);

            mom.MockConnectionFor(id).Setup(c => c.Resolve(masterRef)).Returns(master.Object);
            mom.MockConnectionFor(id).Setup(c => c.Cache.Hosts).Returns(new Host[] { master.Object });
            mom.MockConnectionFor(id).Setup(c => c.Cache.Pools).Returns(new Pool[] { pool.Object });

            master.Setup(h => h.software_version).Returns(new Dictionary<string, string>());
            master.Setup(h => h.ProductVersion).Returns(productVersion);
            master.Setup(h => h.AppliedPatches()).Returns(applied_patches ?? new List<Pool_patch>());
            master.Setup(h => h.BuildNumberRaw).Returns(buildNumber);
            master.Setup(h => h.uuid).Returns(id);
            return master;
        }