Esempio n. 1
0
        public void TotallyCompatible(Type type, bool expected)
        {
            var comparator = (CKAN.IGameComparator)Activator.CreateInstance(type);

            gameMod = RandomModuleGenerator.GeneratorRandomModule(depends: new List <ModDependency> {
                new ModDependency("base==0.12.5")
            });

            // Now test!
            Assert.AreEqual(expected, comparator.Compatible(GameVersion, gameMod));
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        public void Constructor_WithConflictingModules()
        {
            var list  = new List <string>();
            var mod_a = generator.GeneratorRandomModule();
            var mod_b = generator.GeneratorRandomModule(conflicts: new List <RelationshipDescriptor>
            {
                new ModuleRelationshipDescriptor {
                    name = mod_a.identifier
                }
            });

            list.Add(mod_a.identifier);
            list.Add(mod_b.identifier);
            AddToRegistry(mod_a, mod_b);

            Assert.Throws <InconsistentKraken>(() => new RelationshipResolver(
                                                   list,
                                                   null,
                                                   options,
                                                   registry,
                                                   null));


            options.proceed_with_inconsistencies = true;
            var resolver = new RelationshipResolver(list, null, options, registry, null);

            Assert.That(resolver.ConflictList.Any(s => Equals(s.Key, mod_a)));
            Assert.That(resolver.ConflictList.Any(s => Equals(s.Key, mod_b)));
            Assert.That(resolver.ConflictList, Has.Count.EqualTo(2));
        }
Esempio n. 6
0
        public void Constructor_WithConflictingModules_Throws()
        {
            var list  = new List <string>();
            var mod_a = generator.GeneratorRandomModule();
            var mod_b = generator.GeneratorRandomModule(conflicts: new List <RelationshipDescriptor>
            {
                new RelationshipDescriptor {
                    name = mod_a.identifier
                }
            });

            list.Add(mod_a.identifier);
            list.Add(mod_b.identifier);
            AddToRegistry(mod_a, mod_b);

            Assert.Throws <InconsistentKraken>(() => new RelationshipResolver(
                                                   list,
                                                   options,
                                                   registry,
                                                   null));
        }
Esempio n. 7
0
        public void Constructor_WithMissingModules_Throws()
        {
            var list  = new List <string>();
            var mod_a = generator.GeneratorRandomModule();

            list.Add(mod_a.identifier);
            var modList = list.Select(p => new CfanModuleIdAndVersion(p, new ModVersion("1.0")));

            Assert.Throws <ModuleNotFoundKraken>(() => new RelationshipResolver(
                                                     modList,
                                                     options,
                                                     registry,
                                                     null));
        }