public void TestGenerateMapPreviewIcons(string inputFolder) { var mapInfo = MapInfo.Parse(File.OpenRead(Path.Combine(inputFolder, MapInfo.FileName))); var mapEnvironment = MapEnvironment.Parse(File.OpenRead(Path.Combine(inputFolder, MapEnvironment.FileName))); var mapUnits = MapUnits.Parse(File.OpenRead(Path.Combine(inputFolder, MapUnits.FileName))); var expected = MapPreviewIcons.Parse(File.OpenRead(Path.Combine(inputFolder, MapPreviewIcons.FileName))); var actual = new MapPreviewIcons(mapInfo, mapEnvironment, mapUnits); var expectedEnumerator = expected.GetEnumerator(); var actualEnumerator = actual.GetEnumerator(); while (true) { if (expectedEnumerator.MoveNext() & actualEnumerator.MoveNext()) { var expectedIcon = expectedEnumerator.Current; var actualIcon = actualEnumerator.Current; const int delta = 1; Assert.AreEqual(expectedIcon.IconType, actualIcon.IconType); Assert.AreEqual(expectedIcon.X, actualIcon.X, delta); Assert.AreEqual(expectedIcon.Y, actualIcon.Y, delta); Assert.AreEqual(expectedIcon.Color.ToArgb(), actualIcon.Color.ToArgb()); } else if (expectedEnumerator.Current != null || actualEnumerator.Current != null) { Assert.Fail("Expected and actual icon count are not the same."); } else { break; } } }
public void TestParseMapUnits(string mapUnitsFilePath) { using var original = FileProvider.GetFile(mapUnitsFilePath); using var recreated = new MemoryStream(); MapUnits.Parse(original, true).SerializeTo(recreated, true); StreamAssert.AreEqual(original, recreated, true); }
public void TestParseMapUnits(string mapUnitsFilePath) { using var recreated = new MemoryStream(); using var original = File.OpenRead(mapUnitsFilePath); var data = MapUnits.Parse(original, true); Assert.AreEqual(original.Length, original.Position); data.SerializeTo(recreated, true); StreamAssert.AreEqual(original, recreated, true); }
public void TestParseMapUnits(string mapUnitsFilePath) { using var recreated = new MemoryStream(); using var original = File.OpenRead(mapUnitsFilePath); var data = MapUnits.Parse(original, true); Assert.AreEqual(original.Length, original.Position); data.SerializeTo(recreated, true); original.Position = 4; using (var reader = new BinaryReader(original, new UTF8Encoding(false, true), true)) { var version = (MapWidgetsVersion)reader.ReadUInt32(); if (version != MapWidgetsVersion.TFT) { // Can't compare streams, because serialize always saves as TFT, which sets header version to 8 and has additional data per unit. return; } } StreamAssert.AreEqual(original, recreated, true); }