public LevelMapperTest()
 {
     _data     = ThingDemoMap.Create();
     _planeMap = _data.PlaneMaps.Single();
     ClearMap();
     SetupTiles();
 }
Exemple #2
0
        public void ShouldHandleParsingDemoMap()
        {
            var map = ThingDemoMap.Create();

            using var stream = new MemoryStream();
            map.WriteTo(stream);

            stream.Position = 0;

            using var textReader = new StreamReader(stream, Encoding.ASCII);
            var lexer  = new UnifiedLexer(textReader);
            var result = UwmfParser.Parse(lexer.Scan()).ToArray();
        }
Exemple #3
0
        public void ShouldRoundTripDemoMap()
        {
            var map = ThingDemoMap.Create();

            using var stream = new MemoryStream();
            map.WriteTo(stream);

            stream.Position = 0;

            using var textReader = new StreamReader(stream, Encoding.ASCII);
            var roundTripped = UwmfSemanticAnalyzer.ReadMapData(UwmfParser.Parse(new UnifiedLexer(textReader).Scan()));

            UwmfComparison.AssertEqual(roundTripped, map);
        }
        public void ShouldCreateWadFile()
        {
            var fileInfo = new FileInfo(Path.GetTempFileName());

            try
            {
                var lumps = new List <ILump>
                {
                    new Marker("MAP01"),
                    new UwmfLump("TEXTMAP", ThingDemoMap.Create()),
                    new Marker("ENDMAP")
                };
                WadWriter.SaveTo(lumps, fileInfo.FullName);
            }
            finally
            {
                if (fileInfo.Exists)
                {
                    fileInfo.Delete();
                }
            }
        }
        public void ShouldReadCreatedWadFile()
        {
            var fileInfo = new FileInfo(Path.GetTempFileName());

            try
            {
                var map = ThingDemoMap.Create();

                var lumps = new List <ILump>
                {
                    new Marker("MAP01"),
                    new UwmfLump("TEXTMAP", ThingDemoMap.Create()),
                    new Marker("ENDMAP")
                };
                WadWriter.SaveTo(lumps, fileInfo.FullName);

                var wad = WadFile.Read(fileInfo.FullName);
                wad.Should().HaveCount(3);

                wad.Select(l => l.Name).Should().BeEquivalentTo(
                    new[] { new LumpName("MAP01"), new LumpName("TEXTMAP"), new LumpName("ENDMAP"), },
                    "correct lump names should have been read.");

                var mapBytes = wad[1].GetData();
                using var ms = new MemoryStream(mapBytes);
                var roundTripped = UwmfReader.Read(ms);

                UwmfComparison.AssertEqual(roundTripped, map);
            }
            finally
            {
                if (fileInfo.Exists)
                {
                    fileInfo.Delete();
                }
            }
        }