From 35f9219dced3e70e80acbb1dc5964727bae6a12b Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 1 Jan 2024 16:10:33 +0000 Subject: [PATCH] tests for getting missing regions --- RTWLibPlus/randomiser/randDS.cs | 4 +-- RTWLib_Tests/modifiers/Tests_drMod.cs | 35 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 RTWLib_Tests/modifiers/Tests_drMod.cs diff --git a/RTWLibPlus/randomiser/randDS.cs b/RTWLibPlus/randomiser/randDS.cs index 98ef2cb..f54a66a 100644 --- a/RTWLibPlus/randomiser/randDS.cs +++ b/RTWLibPlus/randomiser/randDS.cs @@ -50,8 +50,8 @@ public static string RandCitiesVoronoi(SMF smf, RandWrap rnd, DS ds = null, City Vector2[] vp = Voronoi.GetVoronoiPoints(factions.Count, cm.Width, cm.Height, rnd); List gh = Voronoi.GetVoronoiGroups(cm.CityCoordinates, vp); - //gh.Shuffle(TWRand.rnd); - //factions.Shuffle(TWRand.rnd); + // gh.Shuffle(TWRand.rnd); + // factions.Shuffle(TWRand.rnd); // function to get missing settlements and add them to the pool for (int i = 0; i < factions.Count; i++) { diff --git a/RTWLib_Tests/modifiers/Tests_drMod.cs b/RTWLib_Tests/modifiers/Tests_drMod.cs new file mode 100644 index 0000000..a1215d8 --- /dev/null +++ b/RTWLib_Tests/modifiers/Tests_drMod.cs @@ -0,0 +1,35 @@ +namespace RTWLib_Tests.Modifiers; + +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using RTWLibPlus.data; +using RTWLibPlus.dataWrappers; +using RTWLibPlus.helpers; +using RTWLibPlus.interfaces; +using RTWLibPlus.parsers; +using RTWLibPlus.parsers.objects; +using RTWLibPlus.Modifiers; + +[TestClass] +public class TestsDR +{ + private readonly DepthParse dp = new(); + private readonly TWConfig config = TWConfig.LoadConfig(@"resources/remaster.json"); + + [TestMethod] + public void GetMissingRegions() + { + string[] dr = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_regions.txt"), false); + List smfParse = this.dp.Parse(dr, Creator.DRcreator, '\t'); + DR parseddr = new(smfParse, this.config); + string[] ds = this.dp.ReadFile(RFH.CurrDirPath("resources", "descr_strat.txt"), false); + List dsParse = this.dp.Parse(ds, Creator.DScreator); + DS parsedds = new(dsParse, this.config); + List settlements = parsedds.GetItemsByIdent("settlement").DeepCopy(); + List missing = DRModifier.GetMissingRegionNames(settlements, parseddr); + + int result = settlements.Count + missing.Count; + Assert.AreEqual(parseddr.Regions.Count, result); + } + +}