Add tests hopefully
This commit is contained in:
79
test/mod_list_test.dart
Normal file
79
test/mod_list_test.dart
Normal file
@@ -0,0 +1,79 @@
|
||||
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: '',
|
||||
hardDependencies: [],
|
||||
loadAfter: [],
|
||||
loadBefore: [],
|
||||
incompatabilities: [],
|
||||
size: 0,
|
||||
isBaseGame: false,
|
||||
isExpansion: false,
|
||||
enabled: false,
|
||||
);
|
||||
|
||||
final dummyMods = {
|
||||
'harmony': dummyMod.copyWith(
|
||||
name: 'Harmony',
|
||||
id: 'harmony',
|
||||
loadBefore: ["ludeon.rimworld"],
|
||||
size: 47,
|
||||
enabled: true,
|
||||
),
|
||||
'ludeon.rimworld': dummyMod.copyWith(
|
||||
name: 'RimWorld',
|
||||
id: 'ludeon.rimworld',
|
||||
enabled: true,
|
||||
isBaseGame: true,
|
||||
),
|
||||
'ludeon.rimworld.anomaly': dummyMod.copyWith(
|
||||
name: 'RimWorld Anomaly',
|
||||
id: 'ludeon.rimworld.anomaly',
|
||||
enabled: true,
|
||||
isExpansion: true,
|
||||
),
|
||||
'disabledDummy': dummyMod.copyWith(
|
||||
name: 'Disabled Dummy',
|
||||
id: 'disabledDummy',
|
||||
enabled: false,
|
||||
),
|
||||
};
|
||||
|
||||
final dummyList = ModList(configPath: configPath, modsPath: modsRoot);
|
||||
dummyList.mods.addAll(dummyMods);
|
||||
for (final mod in dummyMods.keys) {
|
||||
dummyList.activeMods[mod] = true;
|
||||
}
|
||||
// final sortedMods = dummyList.sort();
|
||||
final sortedMods = ['harmony', 'ludeon.rimworld', 'ludeon.rimworld.anomaly'];
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user