public void IntersectWithWorksCorrectly(KspVersionRange left, KspVersionRange right, KspVersionRange expected) { // Act var result = left.IntersectWith(right); // Assert Assert.That(result, Is.EqualTo(expected)); }
/// <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); }