Example #1
0
        public void TestLoadMethod()
        {
            const int HEIGHT = 32;
            const int WIDTH = 32;

            Stream stream = File.OpenRead(TEST_FILE);

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

            MovementFile movementFile = new MovementFile();
            movementFile.Load(stream);

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

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(WIDTH, movementFile.Width, "Incorrect width");
            Assert.AreEqual(HEIGHT, movementFile.Height, "Incorrect height");
        }
Example #2
0
        public void TestSaveMethod()
        {
            MovementFile movementFile = new MovementFile();
            movementFile.Load(TEST_FILE);

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

            savedStream.Seek(0, SeekOrigin.Begin);

            MovementFile savedMovementFile = new MovementFile();
            savedMovementFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(movementFile.Width, savedMovementFile.Width, "Width values do not match");
            Assert.AreEqual(movementFile.Height, savedMovementFile.Height, "Height values do not match");

            for (int x = 0; x < movementFile.Height; x++) {
                for (int y = 0; y < movementFile.Width; y++) {
                    Assert.AreEqual(movementFile[x, y], savedMovementFile[x, y], "Values do not match");
                }
            }
        }