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;
            XmlDocument           xdoc;
            XmlNode node;
            String  description;


            //
            // Prepare the test.
            //
            xdoc        = new XmlDocument();
            node        = xdoc.CreateElement("Recommend");
            description = "This is a description of the package.";
            AddXmlAttribute(node, "Description", description);

            //
            // Run the test.
            //
            rec = new PackageRecommendation(node);

            //
            // Verify the test.
            //
            Assert.AreEqual(description, rec.Description);
            Assert.AreEqual("Recommend", rec.NodeName);
        }
        public void BaseConstructorTest()
        {
            PackageRecommendation rec;


            //
            // No preparation needed.
            //

            //
            // Run the test.
            //
            rec = new PackageRecommendation();

            //
            // Verify the test.
            //
            Assert.AreEqual(null, rec.Description);
            Assert.AreEqual("Recommend", rec.NodeName);
        }
        public void XmlConstructorNoDescriptionTest()
        {
            PackageRecommendation rec;
            XmlDocument           xdoc;
            XmlNode node;


            //
            // Prepare the test.
            //
            xdoc = new XmlDocument();
            node = xdoc.CreateElement("Recommend");

            //
            // Run the test.
            //
            rec = new PackageRecommendation(node);

            //
            // Verify the test.
            //
            Assert.AreEqual("", rec.Description);
            Assert.AreEqual("Recommend", rec.NodeName);
        }
Beispiel #5
0
        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);
        }