Beispiel #1
0
        public void TestLoadMethod()
        {
            const int OBJECT_COUNT = 266;

            Stream stream = File.OpenRead(TEST_FILE);

            stream.Seek(0, SeekOrigin.End);
            long fileSize = stream.Position;
            stream.Seek(0, SeekOrigin.Begin);

            LightmapFile lightmapFile = new LightmapFile();
            lightmapFile.Load(stream);

            long streamPosition = stream.Position;
            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(OBJECT_COUNT, lightmapFile.Objects.Count, "Incorrect object count");
        }
Beispiel #2
0
        public void TestSaveMethod()
        {
            LightmapFile lightmapFile = new LightmapFile();
            lightmapFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();
            lightmapFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            LightmapFile savedLightmapFile = new LightmapFile();
            savedLightmapFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(lightmapFile.Objects.Count, savedLightmapFile.Objects.Count, "Object counts do not match");

            for (int i = 0; i < lightmapFile.Objects.Count; i++) {
                Assert.AreEqual(lightmapFile.Objects[i].ID, savedLightmapFile.Objects[i].ID, "Object IDs do not match");
                Assert.AreEqual(lightmapFile.Objects[i].Parts.Count, savedLightmapFile.Objects[i].Parts.Count, "Part counts do not match");

                for (int j = 0; j < lightmapFile.Objects[i].Parts.Count; j++) {
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].Name, savedLightmapFile.Objects[i].Parts[j].Name, "Part names do not match");
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].ID, savedLightmapFile.Objects[i].Parts[j].ID, "Part IDs do not match");
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].FileName, savedLightmapFile.Objects[i].Parts[j].FileName, "Part file names do not match");
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].PixelsPerObject, savedLightmapFile.Objects[i].Parts[j].PixelsPerObject, "Part pixel per object values do not match");
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].ObjectsPerWidth, savedLightmapFile.Objects[i].Parts[j].ObjectsPerWidth, "Part objects per width values do not match");
                    Assert.AreEqual(lightmapFile.Objects[i].Parts[j].ObjectPosition, savedLightmapFile.Objects[i].Parts[j].ObjectPosition, "Part position values do not match");
                }
            }

            Assert.AreEqual(lightmapFile.Files.Count, savedLightmapFile.Files.Count, "File counts do not match");

            for (int i = 0; i < lightmapFile.Files.Count; i++) {
                Assert.AreEqual(lightmapFile.Files[i], savedLightmapFile.Files[i], "File names do not match");
            }
        }