public void IsVisible_WithAllAndNoNameFilter_ReturnsTrueForCompatible() { using (var tidy = new DisposableKSP()) { var config = new FakeConfiguration(tidy.KSP, tidy.KSP.Name); KSPManager manager = new KSPManager( new NullUser(), config ) { CurrentInstance = tidy.KSP }; var ckan_mod = TestData.FireSpitterModule(); var registry = Registry.Empty(); registry.AddAvailable(ckan_mod); var item = new ModList(delegate { }); Assert.That(item.IsVisible( new GUIMod(ckan_mod, registry, manager.CurrentInstance.VersionCriteria()), manager.CurrentInstance.Name )); manager.Dispose(); config.Dispose(); } }
public void ConstructModList_NumberOfRows_IsEqualToNumberOfMods() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(tidy.KSP, tidy.KSP.Name) ) { CurrentInstance = tidy.KSP }; var registry = Registry.Empty(); registry.AddAvailable(TestData.FireSpitterModule()); registry.AddAvailable(TestData.kOS_014_module()); var main_mod_list = new MainModList(null, null); var mod_list = main_mod_list.ConstructModList(new List <GUIMod> { new GUIMod(TestData.FireSpitterModule(), registry, manager.CurrentInstance.VersionCriteria()), new GUIMod(TestData.kOS_014_module(), registry, manager.CurrentInstance.VersionCriteria()) }); Assert.That(mod_list, Has.Count.EqualTo(2)); manager.Dispose(); } }
public void UninstallModNotFound() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeConfiguration(tidy.KSP, tidy.KSP.Name) ) { CurrentInstance = tidy.KSP }; Assert.Throws <ModNotInstalledKraken>(delegate { HashSet <string> possibleConfigOnlyDirs = null; // This should throw, as our tidy KSP has no mods installed. CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(new List <string> { "Foo" }, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance)); }); manager.CurrentInstance = null; // I weep even more. manager.Dispose(); } }
public void InstallList_IdentifierEqualsVersionSyntax_InstallsModule() { using (DisposableKSP ksp = new DisposableKSP()) { // Arrange KSPManager manager = new KSPManager( new NullUser(), new FakeConfiguration(ksp.KSP, ksp.KSP.Name) ) { CurrentInstance = ksp.KSP }; var registry = CKAN.RegistryManager.Instance(ksp.KSP).registry; var inst = CKAN.ModuleInstaller.GetInstance(ksp.KSP, manager.Cache, nullUser); const string mod_file_name = "DogeCoinFlag/Flags/dogecoin.png"; string mod_file_path = Path.Combine(ksp.KSP.GameData(), mod_file_name); CkanModule mod = TestData.DogeCoinFlag_101_module(); registry.AddAvailable(mod); manager.Cache.Store(mod, TestData.DogeCoinFlagZip()); List <string> modules = new List <string>() { $"{mod.identifier}={mod.version}" }; // Act inst.InstallList(modules, new RelationshipResolverOptions()); // Assert Assert.IsTrue(File.Exists(mod_file_path)); manager.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 FakeConfiguration(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(), CKAN.RegistryManager.Instance(manager.CurrentInstance)); 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(), CKAN.RegistryManager.Instance(manager.CurrentInstance)); 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); HashSet <string> possibleConfigOnlyDirs = null; CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList(modules, ref possibleConfigOnlyDirs, CKAN.RegistryManager.Instance(manager.CurrentInstance)); // Check that the directory has been deleted. Assert.IsFalse(Directory.Exists(directoryPath)); manager.Dispose(); } }
public void TearDown() { manager.Dispose(); manager = null; win32_reg = null; tidy.KSP.Dispose(); tidy2.KSP.Dispose(); tidy.Dispose(); tidy2.Dispose(); }
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); KSPManager manager = new KSPManager( new NullUser(), config ) { CurrentInstance = ksp.KSP }; // Make sure the mod is not installed. string mod_file_path = Path.Combine(ksp.KSP.GameData(), 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; CKAN.ModuleInstaller.GetInstance(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 UninstallModNotFound() { KSPManager manager = new KSPManager(new NullUser(), new FakeWin32Registry(ksp.KSP)) { CurrentInstance = ksp.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.Dispose(); }
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); KSPManager manager = new KSPManager( 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; CKAN.ModuleInstaller.GetInstance(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.GameData(), mod_file_name); Assert.IsTrue(File.Exists(mod_file_path)); manager.Dispose(); config.Dispose(); } } }); }
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 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); KSPManager manager = new KSPManager( new NullUser(), config ) { 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 }; HashSet <string> possibleConfigOnlyDirs = null; CKAN.ModuleInstaller.GetInstance(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. CKAN.ModuleInstaller.GetInstance(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 NewGuiModsAreNotSelectedForUpgrade() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(tidy.KSP, tidy.KSP.Name) ) { 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); manager.Dispose(); } }
public void UninstallModNotFound() { using (var tidy = new DisposableKSP()) { KSPManager manager = new KSPManager( new NullUser(), new FakeWin32Registry(tidy.KSP, tidy.KSP.Name) ) { CurrentInstance = tidy.KSP }; Assert.Throws <ModNotInstalledKraken>(delegate { // This should throw, as our tidy KSP has no mods installed. CKAN.ModuleInstaller.GetInstance(manager.CurrentInstance, manager.Cache, nullUser).UninstallList("Foo"); }); manager.CurrentInstance = null; // I weep even more. manager.Dispose(); } }
public void TearDown() { _manager.Dispose(); }
public void TearDown() { manager.Dispose(); tidy.Dispose(); }
public void TearDown() { _manager.Dispose(); _config.Dispose(); _instance.Dispose(); }
public void Down() { _instance.Dispose(); _manager.Dispose(); }