Beispiel #1
0
        public void TestConstructors()
        {
            // Test the empty constructor.
            var version = new XMLVersion();

            Assert.AreEqual(version.MainVersion, 0);
            Assert.AreEqual(version.SubVersion, 0);
            Assert.AreEqual(version.ToString(), "0.0");

            // Test the filled constructor.
            version = new XMLVersion(1, 2);
            Assert.AreEqual(version.MainVersion, 1);
            Assert.AreEqual(version.SubVersion, 2);
            Assert.AreEqual(version.ToString(), "1.2");

            // Test the string constructors.
            version = XMLVersion.FromString(null);
            Assert.IsNull(version);
            version = XMLVersion.FromString("12");
            Assert.AreEqual(version.MainVersion, 12);
            Assert.AreEqual(version.SubVersion, 0);
            Assert.AreEqual(version.ToString(), "12.0");
            version = XMLVersion.FromString("12.13");
            Assert.AreEqual(version.MainVersion, 12);
            Assert.AreEqual(version.SubVersion, 13);
            Assert.AreEqual(version.ToString(), "12.13");
        }
Beispiel #2
0
        public void TestDefaultConstructor()
        {
            // Create the config.
            var config = new ConfigManager();

            // Assert some values are correct.
            Assert.AreEqual(config.GetValue("url"), Properties.Settings.Default.url);
            Assert.AreEqual(config.GetValue("timeout"), Properties.Settings.Default.timeout);
            Assert.AreEqual(config.GetValue("responseDirectory"), Properties.Settings.Default.responseDirectory);
            Assert.AreEqual(config.GetVersion(), XMLVersion.FromString(CnpVersion.CurrentCNPXMLVersion));
        }
Beispiel #3
0
        /*
         * Returns the XML version to use.
         */
        public XMLVersion GetVersion()
        {
            // Return the default if the version is not set.
            if (config["version"] == "")
            {
                Console.WriteLine("Version isn't defined in the configuration. It is recommended " +
                                  "to set it so the SDK version can be upgraded without needing " +
                                  "to change your XML version. Assuming XML version " + CnpVersion.CurrentCNPXMLVersion);

                return(XMLVersion.FromString(CnpVersion.CurrentCNPXMLVersion));
            }

            // Return the version from the string.
            return(XMLVersion.FromString(config["version"]));
        }