|
| 1 | +namespace QMMTests |
| 2 | +{ |
| 3 | + using System; |
| 4 | + using System.Collections.Generic; |
| 5 | + using NUnit.Framework; |
| 6 | + using QModManager.API; |
| 7 | + using QModManager.API.ModLoading; |
| 8 | + using QModManager.Patching; |
| 9 | + |
| 10 | + [TestFixture] |
| 11 | + internal class QModFactoryTests |
| 12 | + { |
| 13 | + [Test] |
| 14 | + public void CreateModStatusList_EarlyErrorsCombineWithSuccessfullMods() |
| 15 | + { |
| 16 | + // Arange |
| 17 | + var earlyErrors = new List<QMod> |
| 18 | + { |
| 19 | + new QMod {Id = "1", Status = ModStatus.CanceledByUser }, |
| 20 | + new QMod {Id = "2", Status = ModStatus.InvalidCoreInfo }, |
| 21 | + new QMod {Id = "3", Status = ModStatus.MissingAssemblyFile }, |
| 22 | + new QMod {Id = "4", Status = ModStatus.MissingDependency }, |
| 23 | + new QMod {Id = "5", Status = ModStatus.MissingPatchMethod }, |
| 24 | + }; |
| 25 | + |
| 26 | + var modsToLoad = new List<QMod> |
| 27 | + { |
| 28 | + new QMod { Id = "6", Status = ModStatus.Success }, |
| 29 | + new QMod { Id = "7", Status = ModStatus.Success }, |
| 30 | + new QMod { Id = "8", Status = ModStatus.Success }, |
| 31 | + }; |
| 32 | + |
| 33 | + // Act |
| 34 | + List<QMod> combinedList = QModFactory.CreateModStatusList(earlyErrors, modsToLoad); |
| 35 | + |
| 36 | + Assert.AreEqual(earlyErrors.Count + modsToLoad.Count, combinedList.Count); |
| 37 | + |
| 38 | + foreach (QMod erroredMod in earlyErrors) |
| 39 | + Assert.IsTrue(combinedList.Contains(erroredMod)); |
| 40 | + |
| 41 | + foreach (QMod readyMod in modsToLoad) |
| 42 | + Assert.IsTrue(combinedList.Contains(readyMod)); |
| 43 | + } |
| 44 | + |
| 45 | + [TestCase("0", ModStatus.MissingDependency)] |
| 46 | + [TestCase("5", ModStatus.MissingDependency)] |
| 47 | + [TestCase("7", ModStatus.OutOfDateDependency)] |
| 48 | + public void CreateModStatusList_WhenMissingVersionDependencies_StatusUpdates(string missingOrOutdatedMod, ModStatus expectedStatus) |
| 49 | + { |
| 50 | + // Arange |
| 51 | + var earlyErrors = new List<QMod> |
| 52 | + { |
| 53 | + new QMod {Id = "5", Status = ModStatus.MissingPatchMethod }, |
| 54 | + }; |
| 55 | + |
| 56 | + var modToInspect = new QMod |
| 57 | + { |
| 58 | + Id = "8", |
| 59 | + Status = ModStatus.Success, |
| 60 | + RequiredMods = new List<RequiredQMod> |
| 61 | + { |
| 62 | + new RequiredQMod(missingOrOutdatedMod, new Version(1, 0, 2)) |
| 63 | + } |
| 64 | + }; |
| 65 | + |
| 66 | + var modsToLoad = new List<QMod> |
| 67 | + { |
| 68 | + new QMod { Id = "6", Status = ModStatus.Success }, |
| 69 | + new QMod |
| 70 | + { |
| 71 | + Id = "7", Status = ModStatus.Success, |
| 72 | + ParsedVersion = new Version(1, 0, 1) |
| 73 | + }, |
| 74 | + modToInspect |
| 75 | + }; |
| 76 | + |
| 77 | + // Act |
| 78 | + List<QMod> combinedList = QModFactory.CreateModStatusList(earlyErrors, modsToLoad); |
| 79 | + |
| 80 | + // Assert |
| 81 | + Assert.AreEqual(expectedStatus, modToInspect.Status); |
| 82 | + } |
| 83 | + } |
| 84 | +} |
0 commit comments