Exemple #1
0
        public void IntersectWithWorksCorrectly(KspVersionRange left, KspVersionRange right, KspVersionRange expected)
        {
            // Act
            var result = left.IntersectWith(right);

            // Assert
            Assert.That(result, Is.EqualTo(expected));
        }
Exemple #2
0
        /// <summary>
        /// If the installed game version is in the given range,
        /// return the given array without the given parameter,
        /// otherwise return the array as-is.
        /// </summary>
        /// <param name="args">Command line parameters to check</param>
        /// <param name="crashyKspRange">Game versions that should not use this parameter</param>
        /// <param name="parameter">The parameter to remove on version match</param>
        /// <returns>
        /// args or args minus parameter
        /// </returns>
        private string[] filterCmdLineArgs(string[] args, KspVersionRange crashyKspRange, string parameter)
        {
            var installedRange = Main.Instance.CurrentInstance.Version().ToVersionRange();

            if (crashyKspRange.IntersectWith(installedRange) != null &&
                args.Contains(parameter))
            {
                log.DebugFormat(
                    "Parameter {0} found on incompatible KSP version {1}, pruning",
                    parameter,
                    Main.Instance.CurrentInstance.Version().ToString());
                return(args.Where(s => s != parameter).ToArray());
            }
            return(args);
        }