public void TestNoCycle5() { // A : B, C // B : E // C : D // E : D // Actual List: (A,) B, C, E, D, D // Reduced Expected list: (A,) B, C, E, D var expected = new List <IMod> { _modA, _modB, _modC, _modE, _modD }; SetModInfo((a, b, c, d, e) => { a.Dependencies.Add(_modB); a.Dependencies.Add(_modC); b.Dependencies.Add(_modE); c.Dependencies.Add(_modD); e.Dependencies.Add(_modD); }); var resolver = new ModDependencyTraverser(_modA); var mods = resolver.Traverse(); CollectionAssert.AreEqual(expected, mods.ToList()); AssertRecursive(expected); }
private void AssertRecursive(ICollection expected) { ResetDependencies(); Assert.IsTrue(_modA.ResolveDependencies(ModDependencyResolveStrategy.FromExistingModsRecursive)); var resolver = new ModDependencyTraverser(_modA); var mods = resolver.Traverse(); CollectionAssert.AreEqual(expected, mods.ToList()); }
private static IList <IMod> GetAllMods(IMod mod) { var traverser = new ModDependencyTraverser(mod); if (traverser.HasDependencyCycles()) { MessageBox.Show("The Mod's dependencies result in a cycles. Cannot Start the Mod!"); return(new List <IMod>(0)); } return(traverser.Traverse()); }
internal void ShowArgs() { if (!(GameObject is IMod mod)) { return; } var traverser = new ModDependencyTraverser(mod); var gameArgs = new GameCommandArguments { Mods = traverser.Traverse() }; var args = gameArgs.ToArgs(); var message = $"Launch Arguments for Mod {GameObject.Name}:\r\n\r\n{args}\r\n\r\nMod's location: '{mod.Identifier}'"; Task.Run(() => MessageBox.Show(message, "FoC Launcher", MessageBoxButton.OK)).Forget(); }
public void TestCycle() { // A : B // B : A // Cycle! SetModInfo((a, b, c, d, e) => { a.Dependencies.Add(_modB); b.Dependencies.Add(_modA); }); var resolver = new ModDependencyTraverser(_modA); Assert.ThrowsException <PetroglyphModException>(() => resolver.Traverse()); Assert.ThrowsException <PetroglyphModException>(() => AssertRecursive(null)); }