public void SaveTest() { PackageRecommendation rec; XmlDocument xdoc; XmlNode node; String description; // // Prepare the test. // xdoc = new XmlDocument(); rec = new PackageRecommendation(); rec.Description = description = "A description of the package."; // // Run the test. // node = rec.Save(xdoc, false); // // Verify the test. // Assert.AreEqual("Recommend", node.Name); Assert.AreEqual(0, node.ChildNodes.Count); Assert.AreEqual(description, node.Attributes["Description"].Value); }
public void XmlConstructorTest() { PackageRecommendation rec; PackageRequirement req; PackageChangelog changelog; VersionRequirement arena; PackageInfo info; XmlDocument xdoc; XmlNode infoNode; String distributor, packagename, version, synopsis, description; // // Prepare the test. // xdoc = new XmlDocument(); infoNode = xdoc.CreateElement("Info"); distributor = "RefrshCache"; AddSimpleXmlNode(infoNode, "Distributor", distributor); packagename = "RC.TestPackage"; AddSimpleXmlNode(infoNode, "PackageName", packagename); version = "3.2.8"; AddSimpleXmlNode(infoNode, "Version", version); synopsis = "This is a short synopsis message."; AddSimpleXmlNode(infoNode, "Synopsis", synopsis); description = "This is a longer description."; AddSimpleXmlNode(infoNode, "Description", description); arena = new VersionRequirement(); arena.Version = new PackageVersion("1.2.3"); arena.MinVersion = new PackageVersion("4.5.6"); arena.MaxVersion = new PackageVersion("7.8.9"); infoNode.AppendChild(arena.Save(xdoc, false).CopyAndRename("ArenaVersion")); req = new PackageRequirement(); req.Name = "RC.Package1"; infoNode.AppendChild(req.Save(xdoc, false)); rec = new PackageRecommendation(); rec.Name = "RC.Package2"; rec.Description = "You should install this."; infoNode.AppendChild(rec.Save(xdoc, false)); changelog = new PackageChangelog(); changelog.Version = new PackageVersion("8.9.982"); changelog.Description = "I made some changes."; infoNode.AppendChild(changelog.Save(xdoc, false)); // // Run the test. // info = new PackageInfo(infoNode); // // Verify the test. // Assert.AreEqual(distributor, info.Distributor); Assert.AreEqual(packagename, info.PackageName); Assert.AreEqual(version, info.Version.ToString()); Assert.AreEqual(synopsis, info.Synopsis); Assert.AreEqual(description, info.Description); Assert.AreEqual(arena.MinVersion.ToString(), info.Arena.MinVersion.ToString()); Assert.AreEqual(arena.MaxVersion.ToString(), info.Arena.MaxVersion.ToString()); Assert.AreEqual(arena.Version.ToString(), info.Arena.Version.ToString()); Assert.AreEqual(1, info.Requires.Count); Assert.AreEqual(1, info.Recommends.Count); Assert.AreEqual(1, info.Changelog.Count); }