示例#1
0
        public void ScanDlls()
        {
            string path     = Path.Combine(ksp.game.PrimaryModDirectory(ksp), "Example.dll");
            var    registry = CKAN.RegistryManager.Instance(ksp).registry;

            Assert.IsFalse(registry.IsInstalled("Example"), "Example should start uninstalled");

            File.WriteAllText(path, "Not really a DLL, are we?");

            ksp.Scan();

            Assert.IsTrue(registry.IsInstalled("Example"), "Example installed");

            ModuleVersion version = registry.InstalledVersion("Example");

            Assert.IsInstanceOf <UnmanagedModuleVersion>(version, "DLL detected as a DLL, not full mod");

            // Now let's do the same with different case.

            string path2 = Path.Combine(ksp.game.PrimaryModDirectory(ksp), "NewMod.DLL");

            Assert.IsFalse(registry.IsInstalled("NewMod"));
            File.WriteAllText(path2, "This text is irrelevant. You will be assimilated");

            ksp.Scan();

            Assert.IsTrue(registry.IsInstalled("NewMod"));
        }