Ejemplo n.º 1
0
        public void VersionWithinBounds_vs_AutoDetectedMod(string version)
        {
            var rd = new CKAN.RelationshipDescriptor {
                version = new CKAN.Version(version)
            };

            Assert.True(rd.version_within_bounds(autodetected));
        }
Ejemplo n.º 2
0
        public void VersionWithinBounds_ExactFalse(string version, string other_version, bool expected)
        {
            var rd = new CKAN.RelationshipDescriptor {
                version = new CKAN.Version(version)
            };

            Assert.AreEqual(expected, rd.version_within_bounds(new CKAN.Version(other_version)));
        }
Ejemplo n.º 3
0
        public void VersionWithinBounds_MinMax_vs_AutoDetectedMod(string min, string max)
        {
            var rd = new CKAN.RelationshipDescriptor
            {
                min_version = new CKAN.Version(min),
                max_version = new CKAN.Version(max)
            };

            Assert.True(rd.version_within_bounds(autodetected));
        }
Ejemplo n.º 4
0
        public void VersionWithinBounds_MinMax(string min, string max, string compare_to, bool expected)
        {
            var rd = new CKAN.RelationshipDescriptor
            {
                min_version = new CKAN.Version(min),
                max_version = new CKAN.Version(max)
            };

            Assert.AreEqual(expected, rd.version_within_bounds(new CKAN.Version(compare_to)));
        }
Ejemplo n.º 5
0
 public void VersionWithinBounds_MinMax_vs_AutoDetectedMod(string min, string max)
 {
     var rd = new CKAN.RelationshipDescriptor
     {
         min_version = new CKAN.Version(min),
         max_version = new CKAN.Version(max)
     };
     
     Assert.True(rd.version_within_bounds(autodetected));
 }
Ejemplo n.º 6
0
        public void VersionWithinBounds_MinMax(string min, string max, string compare_to, bool expected)
        {
            var rd = new CKAN.RelationshipDescriptor
            {
                min_version = new CKAN.Version(min),
                max_version = new CKAN.Version(max)
            };

            Assert.AreEqual(expected, rd.version_within_bounds(new CKAN.Version(compare_to)));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Return the most recent release of a module with a optional ksp version to target and a RelationshipDescriptor to satisfy.
        /// </summary>
        /// <param name="ksp_version">If not null only consider mods which match this ksp version.</param>
        /// <param name="relationship">If not null only consider mods which satisfy the RelationshipDescriptor.</param>
        /// <returns></returns>
        public CkanModule Latest(KspVersionCriteria ksp_version = null, RelationshipDescriptor relationship = null)
        {
            var        available_versions = new List <Version>(module_version.Keys);
            CkanModule module;

            log.DebugFormat("Our dictionary has {0} keys", module_version.Keys.Count);
            log.DebugFormat("Choosing between {0} available versions", available_versions.Count);

            // Uh oh, nothing available. Maybe this existed once, but not any longer.
            if (available_versions.Count == 0)
            {
                return(null);
            }

            // No restrictions? Great, we can just pick the first one!
            if (ksp_version == null && relationship == null)
            {
                module = module_version[available_versions.First()];

                log.DebugFormat("No KSP version restriction, {0} is most recent", module);
                return(module);
            }

            // If there's no relationship to satisfy, we can just pick the first that is
            // compatible with our version of KSP.
            if (relationship == null)
            {
                // Time to check if there's anything that we can satisfy.
                var version =
                    available_versions.FirstOrDefault(v => module_version[v].IsCompatibleKSP(ksp_version));
                if (version != null)
                {
                    return(module_version[version]);
                }

                log.DebugFormat("No version of {0} is compatible with KSP {1}",
                                module_version[available_versions[0]].identifier, ksp_version);

                return(null);
            }

            // If we're here, then we have a relationship to satisfy, so things get more complex.
            if (ksp_version == null)
            {
                var version = available_versions.FirstOrDefault(relationship.version_within_bounds);
                return(version == null ? null : module_version[version]);
            }
            else
            {
                var version = available_versions.FirstOrDefault(v =>
                                                                relationship.version_within_bounds(v) &&
                                                                module_version[v].IsCompatibleKSP(ksp_version));
                return(version == null ? null : module_version[version]);
            }
        }
Ejemplo n.º 8
0
        public void VersionWithinBounds_AllNull()
        {
            var rd = new CKAN.RelationshipDescriptor();

            Assert.True(rd.version_within_bounds(null));
        }
Ejemplo n.º 9
0
        public void VersionWithinBounds_Null(string version)
        {
            var rd = new CKAN.RelationshipDescriptor();

            Assert.True(rd.version_within_bounds(new CKAN.Version(version)));
        }
Ejemplo n.º 10
0
        public void VersionWithinBounds_AllNull()
        {
            var rd = new CKAN.RelationshipDescriptor();

            Assert.True(rd.version_within_bounds(null));        }
Ejemplo n.º 11
0
        public void VersionWithinBounds_Null(string version)
        {
            var rd = new CKAN.RelationshipDescriptor();

            Assert.True(rd.version_within_bounds(new CKAN.Version(version)));
        }
Ejemplo n.º 12
0
        public void VersionWithinBounds_vs_AutoDetectedMod(string version)
        {
            var rd = new CKAN.RelationshipDescriptor { version = new CKAN.Version(version) };

            Assert.True(rd.version_within_bounds(autodetected));
        }
Ejemplo n.º 13
0
 public void VersionWithinBounds_ExactFalse(string version, string other_version, bool expected)
 {
     var rd = new CKAN.RelationshipDescriptor { version = new CKAN.Version(version) };
     Assert.AreEqual(expected, rd.version_within_bounds(new CKAN.Version(other_version)));
 }