private static List <LocalMod> AssertSortSatisfied(List <LocalMod> list) { var sorted = ModLoader.Sort(list); var indexMap = sorted.ToDictionary(m => m.Name, sorted.IndexOf); foreach (var mod in list) { int index = indexMap[mod.Name]; foreach (var dep in mod.properties.sortAfter) { int i; if (indexMap.TryGetValue(dep, out i) && i > index) { Assert.Fail(mod.Name + " sorted after " + dep); } } foreach (var dep in mod.properties.sortBefore) { int i; if (indexMap.TryGetValue(dep, out i) && i < index) { Assert.Fail(mod.Name + " sorted before " + dep); } } } return(sorted); }