public void SaveTest()
        {
            VersionRequirement vr;
            XmlDocument        xdoc;
            XmlNode            node;
            String             MinVersion, MaxVersion, Version;


            //
            // Prepare the test.
            //
            xdoc          = new XmlDocument();
            vr            = new VersionRequirement();
            MinVersion    = "1.2.3";
            vr.MinVersion = new PackageVersion("1.2.3");
            MaxVersion    = "4.5.6";
            vr.MaxVersion = new PackageVersion("4.5.6");
            Version       = "7.8.9";
            vr.Version    = new PackageVersion("7.8.9");

            //
            // Run the test.
            //
            node = vr.Save(xdoc, false);

            //
            // Verify the test.
            //
            Assert.AreEqual(MinVersion, node.Attributes["MinVersion"].Value);
            Assert.AreEqual(MaxVersion, node.Attributes["MaxVersion"].Value);
            Assert.AreEqual(Version, node.Attributes["Version"].Value);
        }
Example #2
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);
        }