public void ComputeChangeSetFromModList_WithEmptyList_HasEmptyChangeSet() { using (var tidy = new DisposableKSP()) { CKAN.KSPManager manager = new CKAN.KSPManager(new NullUser()) { _CurrentInstance = tidy.KSP }; var item = new MainModList(delegate { }); Assert.That(item.ComputeChangeSetFromModList(CKAN.Registry.Empty(), manager.CurrentInstance), Is.Empty); } }
public void CanInstallMod() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. using (DisposableKSP ksp = new DisposableKSP()) { var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; // Make sure the mod is not installed. string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name); Assert.IsFalse(File.Exists(mod_file_path)); // Copy the zip file to the cache directory. Assert.IsFalse(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module())); string cache_path = manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); Assert.IsTrue(manager.Cache.IsCachedZip(TestData.DogeCoinFlag_101_module())); Assert.IsTrue(File.Exists(cache_path)); // Mark it as available in the registry. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; Assert.AreEqual(0, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); Assert.AreEqual(1, registry.CompatibleModules(ksp.KSP.VersionCriteria()).Count()); // Attempt to install it. List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; HashSet <string> possibleConfigOnlyDirs = null; new CKAN.ModuleInstaller(ksp.KSP, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); // Check that the module is installed. Assert.IsTrue(File.Exists(mod_file_path)); manager.Dispose(); config.Dispose(); } }
public void GetPreferredInstance_WithEmptyAutoStartAndMultipleInstances_ReturnsNull() { using (var tidy2 = new DisposableKSP()) { cfg.Instances.Add(new Tuple <string, string, string>("tidy2", tidy2.KSP.GameDir(), "KSP")); // Make a new manager with the updated config var multiMgr = new GameInstanceManager(new NullUser(), cfg); multiMgr.ClearAutoStart(); Assert.That(multiMgr.GetPreferredInstance(), Is.Null); multiMgr.Dispose(); } }
public void UninstallEmptyDirs() { string emptyFolderName = "DogeCoinFlag"; // Create a new disposable KSP instance to run the test on. using (var ksp = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(ksp.KSP, ksp.KSP.Name) ) { CurrentInstance = ksp.KSP }; string directoryPath = Path.Combine(ksp.KSP.GameData(), emptyFolderName); // Install the base test mod. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); List<string> modules = new List<string> { TestData.DogeCoinFlag_101_module().identifier }; CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions()); modules.Clear(); // Install the plugin test mod. manager.Cache.Store(TestData.DogeCoinPlugin_module(), TestData.DogeCoinPluginZip()); registry.AddAvailable(TestData.DogeCoinPlugin_module()); modules.Add(TestData.DogeCoinPlugin_module().identifier); CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions()); modules.Clear(); // Check that the directory is installed. Assert.IsTrue(Directory.Exists(directoryPath)); // Uninstall both mods. modules.Add(TestData.DogeCoinFlag_101_module().identifier); modules.Add(TestData.DogeCoinPlugin_module().identifier); CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules); // Check that the directory has been deleted. Assert.IsFalse(Directory.Exists(directoryPath)); } }
public void Setup() { // By setting these for every test, we can make sure our tests can change // them any way they like without harming other tests. dogezip = TestData.DogeCoinFlagZip(); dogemod = TestData.DogeCoinFlag_101_module(); mm_zip = TestData.ModuleManagerZip(); mm_mod = TestData.ModuleManagerModule(); ksp = new DisposableKSP(); }
public void ModuleManagerInstall() { using (var tidy = new DisposableKSP()) { List <InstallableFile> contents = CKAN.ModuleInstaller.FindInstallableFiles(mm_mod, mm_zip, tidy.KSP); string file = contents .Select(x => x.destination).FirstOrDefault( x => Regex.IsMatch(x, @"ModuleManager\.2\.5\.1\.dll$")); Assert.IsNotNull(file, "ModuleManager install"); } }
public void CloneInstance_GoodInstance_ManagerHasValidInstance() { using (var KSP = new DisposableKSP()) { string instanceName = "newInstance"; string tempdir = TestData.NewTempDir(); manager.CloneInstance(KSP.KSP, instanceName, tempdir); Assert.IsTrue(manager.HasInstance(instanceName)); // Tidy up. System.IO.Directory.Delete(tempdir, true); } }
public void FindInstallableFilesWithKSP(CkanModule mod) { using (var tidy = new DisposableKSP()) { List <InstallableFile> contents = CKAN.ModuleInstaller.FindInstallableFiles(mod, dogezip, tidy.KSP); // See if we can find an expected estination path in the right place. string file = contents .Select(x => x.destination).FirstOrDefault( x => Regex.IsMatch(x, "GameData/DogeCoinFlag/Flags/dogecoin\\.png$")); Assert.IsNotNull(file); } }
public void NewGuiModsAreNotSelectedForUpgrade() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; var registry = Registry.Empty(); var ckan_mod = TestData.kOS_014_module(); registry.AddAvailable(ckan_mod); var mod = new GUIMod(ckan_mod, registry, manager.CurrentInstance.VersionCriteria()); Assert.False(mod.IsUpgradeChecked); } }
public void Up() { _instance = new DisposableKSP(); _registryManager = RegistryManager.Instance(_instance.KSP); _registry = Registry.Empty(); _config = new FakeConfiguration(_instance.KSP, _instance.KSP.Name); _manager = new GameInstanceManager( new NullUser(), _config ); // this module contains a ksp_version of "any" which repros our issue _anyVersionModule = TestData.DogeCoinFlag_101_module(); // install it and set it as pre-installed _manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); _registry.RegisterModule(_anyVersionModule, new string[] { }, _instance.KSP, false); _registry.AddAvailable(_anyVersionModule); HashSet <string> possibleConfigOnlyDirs = null; ModuleInstaller.GetInstance(_instance.KSP, _manager.Cache, _manager.User).InstallList( new List <CkanModule> { { _anyVersionModule } }, new RelationshipResolverOptions(), _registryManager, ref possibleConfigOnlyDirs, new NetAsyncModulesDownloader(_manager.User, _manager.Cache) ); // this module is not for "any" version, to provide another to sort against _registry.AddAvailable(TestData.kOS_014_module()); // test object _modList = new ModList(null); _listGui = new DataGridView(); // todo: refactor the column header code to allow mocking of the GUI without creating columns _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); _listGui.Columns.Add(new DataGridViewCheckBoxColumn()); for (int i = 0; i < 10; i++) { _listGui.Columns.Add(i.ToString(), "Column" + i); } }
public void CloneInstance_ToNotEmptyFolder_ThrowsIOException() { using (var KSP = new DisposableKSP()) { string instanceName = "newInstance"; string tempdir = TestData.NewTempDir(); System.IO.File.Create(System.IO.Path.Combine(tempdir, "shouldntbehere.txt")); Assert.Throws <PathErrorKraken>(() => manager.CloneInstance(KSP.KSP, instanceName, tempdir)); Assert.IsFalse(manager.HasInstance(instanceName)); // Tidy up. System.IO.Directory.Delete(tempdir, true); } }
public void FindInstallbleFilesWithBonusPath(string path) { dogemod.install[0].install_to = path; using (var tidy = new DisposableKSP()) { IEnumerable <InstallableFile> contents = CKAN.ModuleInstaller.FindInstallableFiles( dogemod, dogezip, tidy.KSP ); string file = contents .Select(x => x.destination).FirstOrDefault( x => Regex.IsMatch(x, "GameData/SuchTest/DogeCoinFlag/Flags/dogecoin\\.png$")); Assert.IsNotNull(file); } }
public void IsVisible_WithAllAndNoNameFilter_ReturnsTrueForCompatible() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; var ckan_mod = TestData.FireSpitterModule(); var registry = Registry.Empty(); registry.AddAvailable(ckan_mod); var item = new MainModList(delegate { }, null); Assert.That(item.IsVisible(new GUIMod(ckan_mod, registry, manager.CurrentInstance.Version()))); } }
public void HasUpdateReturnsTrueWhenUpdateAvailible() { using (var tidy = new DisposableKSP()) { var generatror = new RandomModuleGenerator(new Random(0451)); var old_version = generatror.GeneratorRandomModule(version: new ModuleVersion("0.24"), ksp_version: tidy.KSP.Version()); var new_version = generatror.GeneratorRandomModule(version: new ModuleVersion("0.25"), ksp_version: tidy.KSP.Version(), identifier: old_version.identifier); var registry = Registry.Empty(); registry.RegisterModule(old_version, Enumerable.Empty <string>(), null); registry.AddAvailable(new_version); var mod = new GUIMod(old_version, registry, tidy.KSP.VersionCriteria()); Assert.True(mod.HasUpdate); } }
public void ModuleManagerInstancesAreDecoupled() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. Assert.DoesNotThrow(delegate { for (int i = 0; i < 5; i++) { using (DisposableKSP ksp = new DisposableKSP()) { var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; // Copy the zip file to the cache directory. manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); // Mark it as available in the registry. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; registry.AddAvailable(TestData.DogeCoinFlag_101_module()); // Attempt to install it. List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; HashSet <string> possibleConfigOnlyDirs = null; new CKAN.ModuleInstaller(ksp.KSP, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); // Check that the module is installed. string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name); Assert.IsTrue(File.Exists(mod_file_path)); manager.Dispose(); config.Dispose(); } } }); }
public void HasUpdate_OtherModDependsOnCurrent_ReturnsFalse() { // Arrange using (var gameInstWrapper = new DisposableKSP()) { CkanModule olderDepMod = CkanModule.FromJson(@"{ ""spec_version"": ""v1.4"", ""identifier"": ""DependencyMod"", ""version"": ""1.0"", ""ksp_version"": ""1.11.1"", ""download"": ""https://mymods/DM/1.0"" }"); CkanModule newerDepMod = CkanModule.FromJson(@"{ ""spec_version"": ""v1.4"", ""identifier"": ""DependencyMod"", ""version"": ""2.0"", ""ksp_version"": ""1.11.1"", ""download"": ""https://mymods/DM/2.0"" }"); CkanModule dependingMod = CkanModule.FromJson(@"{ ""spec_version"": ""v1.4"", ""identifier"": ""DependingMod"", ""version"": ""1.0"", ""ksp_version"": ""1.11.1"", ""download"": ""https://mymods/DM/2.0"", ""depends"": [ { ""name"": ""DependencyMod"", ""version"": ""1.0"" } ] }"); registry.AddAvailable(olderDepMod); registry.AddAvailable(newerDepMod); registry.AddAvailable(dependingMod); GameInstance gameInst = gameInstWrapper.KSP; registry.RegisterModule(olderDepMod, new string[0], gameInst, false); registry.RegisterModule(dependingMod, new string[0], gameInst, false); GameVersionCriteria crit = new GameVersionCriteria(olderDepMod.ksp_version); // Act bool has = registry.HasUpdate(olderDepMod.identifier, crit); // Assert Assert.IsFalse(has, "Upgrade allowed that would break another mod's dependency"); } }
public void AllowInstallsToScenarios() { // Bogus zip with example to install. var zip = ZipFile.Create(new MemoryStream()); zip.BeginUpdate(); zip.AddDirectory("saves"); zip.AddDirectory("saves/scenarios"); zip.Add(new ZipEntry("/saves/scenarios/AwesomeRace.sfs") { Size = 0, CompressedSize = 0 }); zip.CommitUpdate(); // NB: The spec version really would be "v1.14", but travis is sad when it sees // releases that don't exist yet. var mod = CkanModule.FromJson(@" { ""spec_version"": ""1"", ""identifier"": ""AwesomeMod"", ""version"": ""1.0.0"", ""download"": ""https://awesomemod.example/AwesomeMod.zip"", ""install"": [ { ""file"": ""saves/scenarios/AwesomeRace.sfs"", ""install_to"": ""Scenarios"" } ] }") ; List <InstallableFile> results; using (var ksp = new DisposableKSP()) { results = CKAN.ModuleInstaller.FindInstallableFiles(mod.install.First(), zip, ksp.KSP); Assert.AreEqual( CKAN.KSPPathUtils.NormalizePath( Path.Combine(ksp.KSP.GameDir(), "saves/scenarios/AwesomeRace.sfs") ), results.First().destination ); } }
public async Task TooManyProvidesCallsHandlers() { using (var tidy = new DisposableKSP()) { var manager = new KSPManager(new NullUser()); var registry = Registry.Empty(); var generator = new RandomModuleGenerator(new Random(0451)); var provide_ident = "provide"; var ksp_version = tidy.KSP.Version(); var mod = generator.GeneratorRandomModule(depends: new List <RelationshipDescriptor> { new ModuleRelationshipDescriptor { name = provide_ident } }, ksp_version: ksp_version); var moda = generator.GeneratorRandomModule(provides: new List <string> { provide_ident } , ksp_version: ksp_version); var modb = generator.GeneratorRandomModule(provides: new List <string> { provide_ident } , ksp_version: ksp_version); var choice_of_provide = modb; registry.AddAvailable(mod); registry.AddAvailable(moda); registry.AddAvailable(modb); var installer = ModuleInstaller.GetInstance(tidy.KSP, manager.Cache, null); var main_mod_list = new MainModList(null, async kraken => await Task.FromResult(choice_of_provide)); var a = new HashSet <ModChange> { new ModChange(new GUIMod(mod, registry, new KspVersionCriteria(ksp_version)), GUIModChangeType.Install, null) }; var mod_list = await main_mod_list.ComputeChangeSetFromModList(registry, a, installer, new KspVersionCriteria (ksp_version)); CollectionAssert.AreEquivalent( new[] { new ModChange(new GUIMod(mod, registry, new KspVersionCriteria(ksp_version)), GUIModChangeType.Install, null), new ModChange(new GUIMod(modb, registry, new KspVersionCriteria(ksp_version)), GUIModChangeType.Install, null) }, mod_list); manager.Dispose(); } }
public void Setup() { manager = new KSPManager(new NullUser()); // Give us a registry to play with. ksp = new DisposableKSP(); registry_manager = CKAN.RegistryManager.Instance(ksp.KSP); registry = registry_manager.registry; registry.ClearDlls(); registry.Installed().Clear(); // Make sure we have a registry we can use. CKAN.Repo.Update(registry_manager, ksp.KSP, new NullUser(), TestData.TestKANZip()); // Ready our downloader. async = new CKAN.NetAsyncModulesDownloader(new NullUser(), manager.Cache); // General shortcuts cache = manager.Cache; }
public void UninstallModNotFound() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(tidy.KSP)) { CurrentInstance = tidy.KSP }; Assert.Throws <ModNotInstalledKraken>(delegate { // This should throw, as our tidy KSP has no mods installed. CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, NullUser.User).UninstallList("Foo"); }); manager.CurrentInstance = null; // I weep even more. } }
public void CanUninstallMod() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. using (var ksp = new DisposableKSP()) { var config = new FakeConfiguration(ksp.KSP, ksp.KSP.Name); GameInstanceManager manager = new GameInstanceManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; string mod_file_path = Path.Combine(ksp.KSP.game.PrimaryModDirectory(ksp.KSP), mod_file_name); // Install the test mod. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; HashSet <string> possibleConfigOnlyDirs = null; new CKAN.ModuleInstaller(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions(), CKAN.RegistryManager.Instance(manager.CurrentInstance), ref possibleConfigOnlyDirs); // Check that the module is installed. Assert.IsTrue(File.Exists(mod_file_path)); // Attempt to uninstall it. new CKAN.ModuleInstaller(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance)); // Check that the module is not installed. Assert.IsFalse(File.Exists(mod_file_path)); manager.Dispose(); config.Dispose(); } }
public void ConstructModList_NumberOfRows_IsEqualToNumberOfMods() { using (var tidy = new DisposableKSP()) { CKAN.KSPManager manager = new CKAN.KSPManager(new NullUser()) { _CurrentInstance = tidy.KSP }; var registry = CKAN.Registry.Empty(); registry.AddAvailable(TestData.FireSpitterModule()); registry.AddAvailable(TestData.kOS_014_module()); var modList = MainModList.ConstructModList(new List <GUIMod> { new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.Version()), new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.Version()) }); Assert.That(modList, Has.Count.EqualTo(2)); } }
public void AllowsInstallsToShipsDirectories(string directory) { // Arrange var zip = ZipFile.Create(new MemoryStream()); zip.BeginUpdate(); zip.AddDirectory("ExampleShips"); zip.Add(new ZipEntry("/ExampleShips/AwesomeShip.craft") { Size = 0, CompressedSize = 0 }); zip.CommitUpdate(); var mod = CkanModule.FromJson(string.Format(@" {{ ""spec_version"": 1, ""identifier"": ""AwesomeMod"", ""version"": ""1.0.0"", ""download"": ""https://awesomemod.example/AwesomeMod.zip"", ""install"": [ {{ ""file"": ""ExampleShips/AwesomeShip.craft"", ""install_to"": ""{0}"" }} ] }} ", directory)); // Act List <InstallableFile> results; using (var ksp = new DisposableKSP()) { results = CKAN.ModuleInstaller.FindInstallableFiles(mod.install.First(), zip, ksp.KSP); } // Assert Assert.That( results.Count(i => i.destination.EndsWith(string.Format("/{0}/AwesomeShip.craft", directory))) == 1, Is.True ); }
public void HasUpdateReturnsTrueWhenUpdateAvailible() { using (var tidy = new DisposableKSP()) { CKAN.KSPManager manager = new CKAN.KSPManager(new NullUser()) { _CurrentInstance = tidy.KSP }; var generatror = new RandomModuleGenerator(new Random(0451)); var oldVersion = generatror.GeneratorRandomModule(version: new CKAN.Version("0.24"), kspVersion: tidy.KSP.Version()); var newVersion = generatror.GeneratorRandomModule(version: new CKAN.Version("0.25"), kspVersion: tidy.KSP.Version(), identifier: oldVersion.identifier); var registry = CKAN.Registry.Empty(); registry.RegisterModule(oldVersion, Enumerable.Empty <string>(), null); registry.AddAvailable(newVersion); var mod = new GUIMod(oldVersion, registry, tidy.KSP.Version()); Assert.True(mod.HasUpdate); } }
public void ModuleManagerInstancesAreDecoupled() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. Assert.DoesNotThrow(delegate { for (int i = 0; i < 5; i++) { using (DisposableKSP ksp = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(ksp.KSP, ksp.KSP.Name) ) { CurrentInstance = ksp.KSP }; // Copy the zip file to the cache directory. manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); // Mark it as available in the registry. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; registry.AddAvailable(TestData.DogeCoinFlag_101_module()); // Attempt to install it. List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; CKAN.ModuleInstaller.GetInstance(ksp.KSP, manager.Cache, NullUser.User).InstallList(modules, new RelationshipResolverOptions()); // Check that the module is installed. string mod_file_path = Path.Combine(ksp.KSP.GameData(), mod_file_name); Assert.IsTrue(File.Exists(mod_file_path)); } } }); }
public void SetUp() { _testModule = TestData.DogeCoinFlag_101_module(); _instance = new DisposableKSP(); _registry = CKAN.RegistryManager.Instance(_instance.KSP).registry; _installer = CKAN.ModuleInstaller.GetInstance(_instance.KSP, NullUser.User); _gameDataDir = _instance.KSP.GameData(); _registry.AddAvailable(_testModule); var testModFile = TestData.DogeCoinFlagZip(); _instance.KSP.Cache.Store(_testModule.download, testModFile); _installer.InstallList( new List <string>() { _testModule.identifier }, new RelationshipResolverOptions() ); }
public void Setup() { // Make sure curl is all set up. Curl.Init(); // Give us a registry to play with. ksp = new DisposableKSP(); registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; registry.ClearAvailable(); registry.ClearDlls(); registry.Installed().Clear(); // Make sure we have a registry we can use. CKAN.Repo.UpdateRegistry(TestData.TestKANZip(), registry, ksp.KSP, new NullUser()); // Ready our downloader. async = new CKAN.NetAsyncModulesDownloader(new NullUser()); // General shortcuts cache = ksp.KSP.Cache; }
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")) ); } }
public void CanUninstallMod() { string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; // Create a new disposable KSP instance to run the test on. using (var ksp = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(ksp.KSP, ksp.KSP.Name) ) { CurrentInstance = ksp.KSP }; string mod_file_path = Path.Combine(ksp.KSP.GameData(), mod_file_name); // Install the test mod. var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; manager.Cache.Store(TestData.DogeCoinFlag_101_module(), TestData.DogeCoinFlagZip()); registry.AddAvailable(TestData.DogeCoinFlag_101_module()); List <string> modules = new List <string> { TestData.DogeCoinFlag_101_module().identifier }; CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).InstallList(modules, new RelationshipResolverOptions()); // Check that the module is installed. Assert.IsTrue(File.Exists(mod_file_path)); // Attempt to uninstall it. CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules); // Check that the module is not installed. Assert.IsFalse(File.Exists(mod_file_path)); manager.Dispose(); } }
public void Locking() { using (var ksp = new DisposableKSP()) { // TODO: Give the RegistryManager a way to read-only query // the registry location. var manager = CKAN.RegistryManager.Instance(ksp.KSP); Assert.IsNotNull(manager); var registryPath = CKAN.RegistryManager.Instance(ksp.KSP).lockfilePath; // Let's try opening the same registry file a second time... Assert.IsTrue(TestLock(registryPath)); // And after we dispose the registry manager, the lock should be gone... manager.Dispose(); Assert.IsFalse(TestLock(registryPath)); } }