public void HasUpdate_WithUpgradeableManuallyInstalledMod_ReturnsTrue() { // Arrange using (var gameInstWrapper = new DisposableKSP()) { CkanModule mod = CkanModule.FromJson(@"{ ""spec_version"": ""v1.4"", ""identifier"": ""AutoDetectedMod"", ""version"": ""1.0"", ""ksp_version"": ""1.11.1"", ""download"": ""https://mymods/AD/1.0"" }"); registry.AddAvailable(mod); GameInstance gameInst = gameInstWrapper.KSP; registry.RegisterDll(gameInst, Path.Combine( gameInst.GameDir(), "GameData", $"{mod.identifier}.dll")); GameVersionCriteria crit = new GameVersionCriteria(mod.ksp_version); // Act bool has = registry.HasUpdate(mod.identifier, crit); // Assert Assert.IsTrue(has, "Can't upgrade manually installed DLL"); } }
public static void ScanGameData() { RegistryManager registry_manager = RegistryManager.Instance(); Registry registry = registry_manager.registry; // Forget that we've seen any DLLs, as we're going to refresh them all. registry.ClearDlls(); // TODO: It would be great to optimise this to skip .git directories and the like. // Yes, I keep my GameData in git. string[] dllFiles = Directory.GetFiles(GameData(), "*.dll", SearchOption.AllDirectories); foreach (string file in dllFiles) { // register_dll does the heavy lifting of turning it into a modname registry.RegisterDll(file); } registry_manager.Save(); }
public void AutodetectedCanSatisfyRelationships() { using (var ksp = new DisposableKSP()) { registry.RegisterDll(ksp.KSP, Path.Combine(ksp.KSP.GameData(), "ModuleManager.dll")); var depends = new List <CKAN.RelationshipDescriptor>(); depends.Add(new CKAN.RelationshipDescriptor { name = "ModuleManager" }); CkanModule mod = generator.GeneratorRandomModule(depends: depends); new RelationshipResolver( new CkanModule[] { mod }, RelationshipResolver.DefaultOpts(), registry, new KspVersionCriteria(KspVersion.Parse("1.0.0")) ); } }