94 lines
2.9 KiB
Dart
94 lines
2.9 KiB
Dart
import 'package:rimworld_modman/mod.dart';
|
|
import 'package:rimworld_modman/mod_list.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
const root = r'C:/Users/Administrator/Seafile/Games-RimWorld';
|
|
const modsRoot = '$root/294100';
|
|
const configRoot = '$root/AppData/RimWorld by Ludeon Studios/Config';
|
|
const configPath = '$configRoot/ModsConfig.xml';
|
|
const logsPath = '$root/ModManager';
|
|
|
|
void main() {
|
|
final dummyMod = Mod(
|
|
name: 'Dummy Mod',
|
|
id: 'dummy',
|
|
path: '',
|
|
versions: ["1.5"],
|
|
description: '',
|
|
dependencies: [],
|
|
loadAfter: [],
|
|
loadBefore: [],
|
|
incompatibilities: [],
|
|
size: 0,
|
|
isBaseGame: false,
|
|
isExpansion: false,
|
|
enabled: false,
|
|
);
|
|
|
|
final dummyMods = {
|
|
'harmony': dummyMod.copyWith(
|
|
name: 'Harmony',
|
|
id: 'harmony',
|
|
loadBefore: ["ludeon.rimworld"],
|
|
size: 47,
|
|
),
|
|
'ludeon.rimworld': dummyMod.copyWith(
|
|
name: 'RimWorld',
|
|
id: 'ludeon.rimworld',
|
|
isBaseGame: true,
|
|
),
|
|
'ludeon.rimworld.anomaly': dummyMod.copyWith(
|
|
name: 'RimWorld Anomaly',
|
|
id: 'ludeon.rimworld.anomaly',
|
|
isExpansion: true,
|
|
),
|
|
'disabledDummy': dummyMod.copyWith(
|
|
name: 'Disabled Dummy',
|
|
id: 'disabledDummy',
|
|
),
|
|
'yuuuge': dummyMod.copyWith(name: 'Yuuuge', id: 'yuuuge', size: 1000000),
|
|
'smol': dummyMod.copyWith(name: 'Smol', id: 'smol', size: 1),
|
|
'incompatible': dummyMod.copyWith(
|
|
name: 'Incompatible',
|
|
id: 'incompatible',
|
|
size: 1,
|
|
incompatibilities: ['harmony'],
|
|
),
|
|
};
|
|
|
|
final dummyList = ModList(configPath: configPath, modsPath: modsRoot);
|
|
dummyList.mods.addAll(dummyMods);
|
|
for (final mod in dummyMods.keys) {
|
|
dummyList.setEnabled(mod, true);
|
|
}
|
|
dummyList.setEnabled('disabledDummy', false);
|
|
dummyList.setEnabled('incompatible', false);
|
|
final sortedMods = dummyList.generateLoadOrder();
|
|
|
|
group('Test sorting', () {
|
|
test('Harmony should load before RimWorld', () {
|
|
final harmonyIndex = sortedMods.indexOf('harmony');
|
|
final rimworldIndex = sortedMods.indexOf('ludeon.rimworld');
|
|
expect(harmonyIndex, lessThan(rimworldIndex));
|
|
});
|
|
test('RimWorld should load before Anomaly', () {
|
|
final rimworldIndex = sortedMods.indexOf('ludeon.rimworld');
|
|
final anomalyIndex = sortedMods.indexOf('ludeon.rimworld.anomaly');
|
|
expect(rimworldIndex, lessThan(anomalyIndex));
|
|
});
|
|
test('Disabled dummy mod should not be loaded', () {
|
|
final disabledIndex = sortedMods.indexOf('disabledDummy');
|
|
expect(disabledIndex, isNegative);
|
|
});
|
|
test("yuuuge mod should load before smol", () {
|
|
final smolIndex = sortedMods.indexOf('smol');
|
|
final yuuugeIndex = sortedMods.indexOf('yuuuge');
|
|
expect(yuuugeIndex, lessThan(smolIndex));
|
|
});
|
|
dummyList.setEnabled('incompatible', true);
|
|
test('Error generating load order with incompatible mods', () {
|
|
expect(() => dummyList.generateLoadOrder(), throwsException);
|
|
});
|
|
});
|
|
}
|