Ejemplo n.º 1
0
        /// <summary>
        /// Returns whether the given constraint matches the desired version
        /// for the mod we're processing.
        /// </summary>
        private static bool ConstraintPasses(string op, ModuleVersion version, ModuleVersion desiredVersion)
        {
            switch (op)
            {
            case "":
            case "=":
                return(version.IsEqualTo(desiredVersion));

            case "<":
                return(version.IsLessThan(desiredVersion));

            case ">":
                return(version.IsGreaterThan(desiredVersion));

            case "<=":
                return(version.CompareTo(desiredVersion) <= 0);

            case ">=":
                return(version.CompareTo(desiredVersion) >= 0);

            default:
                throw new Kraken(
                          string.Format("Unknown x_netkan_override comparator: {0}", op));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if we support at least spec_version of the CKAN spec.
        /// </summary>
        internal static bool IsSpecSupported(ModuleVersion spec_vesion)
        {
            // This could be a read-only state variable; do we have those in C#?
            ModuleVersion release = new ModuleVersion(Meta.GetVersion(VersionFormat.Short));

            return(release == null || release.IsGreaterThan(spec_vesion));
        }
Ejemplo n.º 3
0
        public void AgExt()
        {
            var v1 = new ModuleVersion("1.20");
            var v2 = new ModuleVersion("1.22a");

            Assert.That(v2.IsGreaterThan(v1));
        }
Ejemplo n.º 4
0
        public void UnevenVersioning()
        {
            var v0 = new ModuleVersion("1.1.0.0");
            var v1 = new ModuleVersion("1.1.1");

            Assert.That(v0.IsLessThan(v1));
            Assert.That(v1.IsGreaterThan(v0));
        }
Ejemplo n.º 5
0
        public void SortAllNonNumbersBeforeDot()
        {
            var v0 = new ModuleVersion("1.0_beta");
            var v1 = new ModuleVersion("1.0.1_beta");

            Assert.That(v0.IsLessThan(v1));
            Assert.That(v1.IsGreaterThan(v0));
        }
Ejemplo n.º 6
0
        public void Complex()
        {
            var v1 = new ModuleVersion("v6a12");
            var v2 = new ModuleVersion("v6a5");

            Assert.That(v2.IsLessThan(v1));
            Assert.That(v1.IsGreaterThan(v2));
            Assert.That(!v1.IsEqualTo(v2));
        }
Ejemplo n.º 7
0
        public void Basic()
        {
            var v0 = new ModuleVersion("1.2.0");
            var v1 = new ModuleVersion("1.2.0");
            var v2 = new ModuleVersion("1.2.1");

            Assert.That(v1.IsLessThan(v2));
            Assert.That(v2.IsGreaterThan(v1));
            Assert.That(v1.IsEqualTo(v0));
        }
Ejemplo n.º 8
0
        public void DotSeparatorForExtraData()
        {
            var v0 = new ModuleVersion("1.0");
            var v1 = new ModuleVersion("1.0.repackaged");
            var v2 = new ModuleVersion("1.0.1");

            Assert.That(v0.IsLessThan(v1));
            Assert.That(v1.IsLessThan(v2));
            Assert.That(v1.IsGreaterThan(v0));
            Assert.That(v2.IsGreaterThan(v1));
        }
Ejemplo n.º 9
0
        public void SpecCompareAssumptions()
        {
            // These are checks to make sure our assumptions regarding
            // spec versions hold.

            // The *old* CKAN spec had a version number of "1".
            // It should be accepted by any client with an old version number,
            // as well as any with a new version number.
            var old_spec = new ModuleVersion("1");
            var old_dev  = new ModuleVersion("v0.23");
            var new_dev  = new ModuleVersion("v1.2.3");

            Assert.IsTrue(old_dev.IsGreaterThan(old_spec));
            Assert.IsTrue(new_dev.IsGreaterThan(old_spec));

            // The new spec requires a minimum number (v1.2, v1.4)
            // Make sure our assumptions here hold, too.

            var readable_spec   = new ModuleVersion("v1.2");
            var unreadable_spec = new ModuleVersion("v1.4");

            Assert.IsTrue(new_dev.IsGreaterThan(readable_spec));
            Assert.IsFalse(new_dev.IsGreaterThan(unreadable_spec));
        }