Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        public void TestDefaultTileset(string environmentFilePath)
        {
            using var fileStream = File.OpenRead(environmentFilePath);
            var environment = MapEnvironment.Parse(fileStream);

            Assert.IsTrue(environment.IsDefaultTileset());
        }
Ejemplo n.º 3
0
        public void TestDefaultMapEnvironment()
        {
            // Get World Editor default environment file.
            using var defaultEnvironmentStream = File.OpenRead(TestDataProvider.GetFile(@"MapFiles\DefaultMapFiles\war3map.w3e"));
            var defaultMapEnvironment = MapEnvironment.Parse(defaultEnvironmentStream, true);

            defaultEnvironmentStream.Position = 0;

            // Get War3Net default environment file.
            var mapEnvironment = MapEnvironment.Default;

            // Update defaults that are different.
            var tileEnumerator = defaultMapEnvironment.GetEnumerator();

            foreach (var tile in mapEnvironment)
            {
                tileEnumerator.MoveNext();
                tile.Variation      = tileEnumerator.Current.Variation;
                tile.CliffVariation = tileEnumerator.Current.CliffVariation;
            }

            // Compare files.
            using var mapEnvironmentStream = new MemoryStream();
            mapEnvironment.SerializeTo(mapEnvironmentStream, true);
            mapEnvironmentStream.Position = 0;

            StreamAssert.AreEqual(defaultEnvironmentStream, mapEnvironmentStream);
        }
Ejemplo n.º 4
0
        public void TestParseMapEnvironment(string environmentFilePath)
        {
            using var original  = FileProvider.GetFile(environmentFilePath);
            using var recreated = new MemoryStream();

            MapEnvironment.Parse(original, true).SerializeTo(recreated, true);
            StreamAssert.AreEqual(original, recreated, true);
        }