/// <summary> /// Updates the model from the specified server. /// </summary> /// <param name="server">The server.</param> /// <returns></returns> public bool Update(Server server) { var updated = false; foreach (var job in server.Jobs) { bool jobUpdated; var jobName = job.Name; if (Contains(jobName)) { var jobModel = Jobs.First(j => string.Compare(j.Name, jobName, true) == 0); jobUpdated = jobModel.Update(job); } else { Jobs.Add(new JobModel(job)); jobUpdated = true; } if (jobUpdated) updated = true; } return updated; }
public void TestUpdateWhenNoJobs() { var server = new Server(); server.Jobs.Add(JobFactory.Create()); var updated = model.Update(server); Assert.IsTrue(updated); }
/// <summary> /// Maps the specified XML to a <see cref="Server"/> object. /// </summary> /// <param name="xml">The XML.</param> /// <returns></returns> public Server Map(XmlDocument xml) { Server server = null; if (xml != null) { server = new Server { Description = xml.Find("//description"), Url = xml.FindUri("//url") }; } return server; }