Ejemplo n.º 1
0
        public void ReadInvalidStream()
        {
            var r = new BspReader(new MemoryStream());

            r.ReadInfo();
            r.Dispose();
        }
Ejemplo n.º 2
0
        public void ReadLumpDataDisposed()
        {
            var reader = new BspReader(MAP_FILENAME);

            reader.Dispose();
            reader.ReadLumpData(0);
        }
Ejemplo n.º 3
0
        public void ReadEmptyFile()
        {
            var r = new BspReader(EMPTY_FILE_FILENAME);

            r.ReadInfo();
            r.Dispose();
        }
Ejemplo n.º 4
0
        public void WriteAndValidateOtherData()
        {
            var lumpToEdit = 39;

            byte[] oldData;

            using (var reader = new BspReader(TEMP_FILENAME))
            {
                oldData = reader.ReadLumpData(40);
            }

            using (var writer = new BspLumpDataWriter(TEMP_FILENAME, OUTPUT_FILENAME))
            {
                writer.WriteLumpData(lumpToEdit, exampleData);
            }

            using (var reader = new BspReader(OUTPUT_FILENAME))
            {
                var newData = reader.ReadLumpData(40);

                for (int i = 0; i < newData.Length; i++)
                {
                    byte oldByte = oldData[i];
                    byte newByte = newData[i];

                    Assert.AreEqual(oldByte, newByte);
                }
            }
        }
Ejemplo n.º 5
0
        public void ReadInfoDisposed()
        {
            var reader = new BspReader(MAP_FILENAME);

            reader.Dispose();
            reader.ReadInfo();
        }
Ejemplo n.º 6
0
        public void ReadInvalidHeader()
        {
            var r = new BspReader(NOT_BSP_FILE_FILENAME);

            r.ReadInfo();
            r.Dispose();
        }
Ejemplo n.º 7
0
        public void OneNullComparison()
        {
            var r     = new BspReader(MAP_FILENAME);
            var info1 = r.ReadInfo();

            r.Dispose();

            Assert.AreNotEqual(info1, null);
        }
Ejemplo n.º 8
0
        public void ReadLumpDataById()
        {
            var r    = new BspReader(MAP_FILENAME);
            var data = r.ReadLumpData(40);

            r.Dispose();

            Assert.IsInstanceOfType(data, typeof(byte[]));
            Assert.IsNotNull(data);
        }
Ejemplo n.º 9
0
        public void ReadLumpInfoById()
        {
            var r    = new BspReader(MAP_FILENAME);
            var lump = r.ReadLumpInfo(40);

            r.Dispose();

            Assert.IsInstanceOfType(lump, typeof(BspLumpInfo));
            Assert.IsNotNull(lump);
        }
Ejemplo n.º 10
0
        public void ReadInfo()
        {
            var r    = new BspReader(MAP_FILENAME);
            var info = r.ReadInfo();

            r.Dispose();

            Assert.IsInstanceOfType(info, typeof(BspInfo));
            Assert.IsNotNull(info);
        }
Ejemplo n.º 11
0
 public void CtorReadFromBinaryReader()
 {
     using (var stream = new FileStream(MAP_FILENAME, FileMode.Open))
     {
         using (var reader = new BinaryReader(stream))
         {
             var r = new BspReader(reader);
         }
     }
 }
Ejemplo n.º 12
0
        public void WriteAndValidateLumpInfo()
        {
            WriteLumpInfo();

            var reader       = new BspReader(TEMP_FILENAME);
            var tempLumpInfo = reader.ReadLumpInfo(0);

            reader.Dispose();

            Assert.AreEqual(tempLumpInfo, exampleLump);
        }
Ejemplo n.º 13
0
        public void ComparisonTest()
        {
            var r     = new BspReader(MAP_FILENAME);
            var info1 = r.ReadInfo();

            r.Dispose();

            r = new BspReader(MAP_FILENAME);
            var info2 = r.ReadInfo();

            r.Dispose();

            Assert.AreEqual(info1, info2);
        }
Ejemplo n.º 14
0
        public void WriteData()
        {
            var lumpToEdit = 39;

            using (var writer = new BspLumpDataWriter(TEMP_FILENAME, OUTPUT_FILENAME))
            {
                writer.WriteLumpData(lumpToEdit, exampleData);
            }

            using (var reader = new BspReader(OUTPUT_FILENAME))
            {
                Assert.AreEqual(exampleData.Length, reader.ReadLumpData(lumpToEdit).Length);
            }
        }
Ejemplo n.º 15
0
        public void ReadInCustomOrder()
        {
            var reader    = new BspReader(MAP_FILENAME);
            var reference = reader.ReadInfo();

            reader.Dispose();

            reader = new BspReader(MAP_FILENAME);
            var meaninglessVar = reader.ReadLumpInfo(BspLumpType.LUMP_PAKFILE);
            var tested         = reader.ReadInfo();

            reader.Dispose();

            Assert.AreEqual(reference, tested);
        }
Ejemplo n.º 16
0
        public void ReadLumpDataDisposedMessage()
        {
            var reader = new BspReader(MAP_FILENAME);

            reader.Dispose();
            try
            {
                reader.ReadLumpData(0);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                Assert.AreEqual(ex.Message, exceptionMessage);
            }
        }
Ejemplo n.º 17
0
        public void CtorReadFile()
        {
            var r = new BspReader(MAP_FILENAME);

            r.Dispose();
        }
Ejemplo n.º 18
0
        public void CtorReadFromStream()
        {
            var r = new BspReader((Stream)(new FileStream(MAP_FILENAME, FileMode.Open)));

            r.Dispose();
        }