예제 #1
0
 public void Setup()
 {
     registry = CKAN.Registry.Empty();
     options = RelationshipResolver.DefaultOpts();
     generator = new RandomModuleGenerator(new Random(0451));
     //Sanity checker means even incorrect RelationshipResolver logic was passing
     options.without_enforce_consistency = true;
 }
예제 #2
0
        public void HasUpdateReturnsTrueWhenUpdateAvailible()
        {
            using (var tidy = new DisposableKSP())
            {
                var generatror = new RandomModuleGenerator(new Random(0451));
                var old_version = generatror.GeneratorRandomModule(version: new Version("0.24"), ksp_version: tidy.KSP.Version());
                var new_version = generatror.GeneratorRandomModule(version: new Version("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.Version());
                Assert.True(mod.HasUpdate);
            }
        }
예제 #3
0
파일: MainModList.cs 프로젝트: Zor-X-L/CKAN
        public async Task TooManyProvidesCallsHandlers()
        {
            using (var tidy = new DisposableKSP())
            {
                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 RelationshipDescriptor {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, 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,ksp_version), GUIModChangeType.Install, null)
                };

                var mod_list = await main_mod_list.ComputeChangeSetFromModList(registry, a, installer, ksp_version);
                CollectionAssert.AreEquivalent(
                    new[] {
                        new ModChange(new GUIMod(mod,registry,ksp_version), GUIModChangeType.Install, null),
                        new ModChange(new GUIMod(modb,registry,ksp_version),GUIModChangeType.Install, null)
                    }, mod_list);

            }
        }