コード例 #1
0
        public void ModList_WithInstalledModules_DoesNotContainThem()
        {
            var list  = new List <string>();
            var mod_a = generator.GeneratorRandomModule();

            list.Add(mod_a.identifier);
            AddToRegistry(mod_a);
            registry.Installed().Add(mod_a.identifier, mod_a.version);

            var relationship_resolver = new RelationshipResolver(list, options, registry, null);

            CollectionAssert.IsEmpty(relationship_resolver.ModList());
        }
コード例 #2
0
ファイル: RelationshipResolver.cs プロジェクト: zicrog/CKAN
        public void Constructor_ReverseDependencyConflictsLatest_ChoosesOlderVersion()
        {
            // Arrange
            CkanModule depender = CkanModule.FromJson(@"{
                ""identifier"": ""depender"",
                ""version"":    ""1.0"",
                ""download"":   ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
                ""depends"": [ { ""name"": ""dependency"" } ]
            }");

            CkanModule olderDependency = CkanModule.FromJson(@"{
                ""identifier"": ""dependency"",
                ""version"":    ""1.0"",
                ""download"":   ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01""
            }");

            CkanModule newerDependency = CkanModule.FromJson(@"{
                ""identifier"": ""dependency"",
                ""version"":    ""2.0"",
                ""download"":   ""https://kerbalstuff.com/mod/269/Dogecoin%20Flag/download/1.01"",
                ""conflicts"": [ {
                    ""name"": ""depender""
                } ]
            }");

            AddToRegistry(olderDependency, newerDependency, depender);

            // Act
            RelationshipResolver rr = new RelationshipResolver(
                new CkanModule[] { depender }, null,
                options, registry, null
                );

            // Assert
            CollectionAssert.Contains(rr.ModList(), olderDependency);
            CollectionAssert.DoesNotContain(rr.ModList(), newerDependency);
        }
コード例 #3
0
ファイル: RelationshipResolver.cs プロジェクト: zicrog/CKAN
        public void ReasonFor_WithModsNotInList_ThrowsArgumentException()
        {
            var list = new List <string>();
            var mod  = generator.GeneratorRandomModule();

            list.Add(mod.identifier);
            registry.AddAvailable(mod);
            AddToRegistry(mod);
            var relationship_resolver = new RelationshipResolver(list, null, options, registry, null);

            var mod_not_in_resolver_list = generator.GeneratorRandomModule();

            CollectionAssert.DoesNotContain(relationship_resolver.ModList(), mod_not_in_resolver_list);
            Assert.Throws <ArgumentException>(() => relationship_resolver.ReasonFor(mod_not_in_resolver_list));
        }
コード例 #4
0
ファイル: RelationshipResolver.cs プロジェクト: trakos/CFAN
        public void Constructor_WithSuggests_HasSugestedInModlist()
        {
            options.with_all_suggests = true;
            var list     = new List <string>();
            var sugested = generator.GeneratorRandomModule();
            var sugester = generator.GeneratorRandomModule(depends: new List <ModDependency>
            {
                new ModDependency($"? {sugested.identifier}")
            });

            list.Add(sugester.identifier);
            AddToRegistry(sugester, sugested);

            var modList = list.Select(p => new CfanModuleIdAndVersion(p));
            var relationship_resolver = new RelationshipResolver(modList, options, registry, null);

            Assert.True(relationship_resolver.ModList().Any(p => p.ToString() == sugested.ToString()));
        }
コード例 #5
0
ファイル: RelationshipResolver.cs プロジェクト: zicrog/CKAN
        public void Constructor_WithSuggests_HasSuggestedInModlist()
        {
            options.with_all_suggests = true;
            var list      = new List <string>();
            var suggested = generator.GeneratorRandomModule();
            var suggester = generator.GeneratorRandomModule(suggests: new List <RelationshipDescriptor>
            {
                new ModuleRelationshipDescriptor {
                    name = suggested.identifier
                }
            });

            list.Add(suggester.identifier);
            AddToRegistry(suggester, suggested);

            var relationship_resolver = new RelationshipResolver(list, null, options, registry, null);

            CollectionAssert.Contains(relationship_resolver.ModList(), suggested);
        }
コード例 #6
0
        public void ModList_WithInstalledModulesSugested_DoesNotContainThem()
        {
            options.with_all_suggests = true;
            var list     = new List <string>();
            var sugested = generator.GeneratorRandomModule();
            var sugester = generator.GeneratorRandomModule(sugests: new List <RelationshipDescriptor>
            {
                new RelationshipDescriptor {
                    name = sugested.identifier
                }
            });

            list.Add(sugester.identifier);
            AddToRegistry(sugester, sugested);
            registry.Installed().Add(sugested.identifier, sugested.version);

            var relationship_resolver = new RelationshipResolver(list, options, registry, null);

            CollectionAssert.Contains(relationship_resolver.ModList(), sugested);
        }
コード例 #7
0
ファイル: RelationshipResolver.cs プロジェクト: trakos/CFAN
        public void Constructor_WithDependantVersionMinMax_ChooseCorrectly(string ver, string dep_min, string dep_max, string other)
        {
            var list            = new List <string>();
            var dependant       = generator.GeneratorRandomModule(version: new Version(ver));
            var other_dependant = generator.GeneratorRandomModule(identifier: dependant.identifier, version: new Version(other));

            var depender = generator.GeneratorRandomModule(depends: new List <ModDependency>
            {
                new ModDependency($"{dependant.identifier}>={dep_min}<={dep_max}")
            });

            list.Add(depender.identifier);
            AddToRegistry(depender, dependant, other_dependant);

            var modList = list.Select(p => new CfanModuleIdAndVersion(p));
            var relationship_resolver = new RelationshipResolver(modList, options, registry, null);

            CollectionAssert.AreEquivalent(relationship_resolver.ModList(), new List <CfanModule>
            {
                dependant,
                depender
            });
        }
コード例 #8
0
ファイル: RelationshipResolver.cs プロジェクト: zicrog/CKAN
        public void Constructor_WithDependantVersionMinMax_ChooseCorrectly(string ver, string dep_min, string dep_max, string other)
        {
            var list            = new List <string>();
            var dependant       = generator.GeneratorRandomModule(version: new ModuleVersion(ver));
            var other_dependant = generator.GeneratorRandomModule(identifier: dependant.identifier, version: new ModuleVersion(other));

            var depender = generator.GeneratorRandomModule(depends: new List <RelationshipDescriptor>
            {
                new ModuleRelationshipDescriptor {
                    name = dependant.identifier, min_version = new ModuleVersion(dep_min), max_version = new ModuleVersion(dep_max)
                }
            });

            list.Add(depender.identifier);
            AddToRegistry(depender, dependant, other_dependant);

            var relationship_resolver = new RelationshipResolver(list, null, options, registry, null);

            CollectionAssert.AreEquivalent(relationship_resolver.ModList(), new List <CkanModule>
            {
                dependant,
                depender
            });
        }