public void TestAlertWithConnectionAndHosts() { XenServerVersion ver = new XenServerVersion("1.2.3", "name", true, "http://url", new List<XenServerPatch>(), new List<XenServerPatch>(), new DateTime(2011, 4, 1).ToString(), "123"); var alert = new XenServerVersionAlert(ver); alert.IncludeConnection(connA.Object); alert.IncludeConnection(connB.Object); alert.IncludeHosts(new List<Host>() { hostA.Object, hostB.Object }); IUnitTestVerifier validator = new VerifyGetters(alert); validator.Verify(new AlertClassUnitTestData { AppliesTo = "HostAName, HostBName, ConnAName, ConnBName", FixLinkText = "Go to Web Page", HelpID = "XenServerUpdateAlert", Description = "name is now available. Download the latest at the " + XenAdmin.Branding.COMPANY_NAME_SHORT + " website.", HelpLinkText = "Help", Title = "name is now available", Priority = "Priority5" }); Assert.IsFalse(alert.CanIgnore); VerifyConnExpectations(Times.Once); VerifyHostsExpectations(Times.Once); }
public static XenServerVersionAlert NewXenServerVersionAlert(List<XenServerVersion> xenServerVersions) { if (Helpers.CommonCriteriaCertificationRelease) return null; var latestVersion = xenServerVersions.FindAll(item => item.Latest).OrderByDescending(v => v.Version).FirstOrDefault(); if (latestVersion == null) return null; var alert = new XenServerVersionAlert(latestVersion); foreach (IXenConnection xc in ConnectionsManager.XenConnectionsCopy) { if (!xc.IsConnected) continue; Host master = Helpers.GetMaster(xc); Pool pool = Helpers.GetPoolOfOne(xc); List<Host> hosts = xc.Cache.Hosts.ToList(); if (master == null || pool == null) continue; var outOfDateHosts = hosts.Where(host => new Version(Helpers.HostProductVersion(host)) < latestVersion.Version); if (outOfDateHosts.Count() == hosts.Count) alert.IncludeConnection(xc); else alert.IncludeHosts(outOfDateHosts); } return alert; }