コード例 #1
0
ファイル: SpriteFileTests.cs プロジェクト: Jiwan/Revise
        public void TestSaveMethod()
        {
            SpriteFile spriteFile = new SpriteFile();
            spriteFile.Load(TEST_FILE);

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

            savedStream.Seek(0, SeekOrigin.Begin);

            SpriteFile savedSpriteFile = new SpriteFile();
            savedSpriteFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(spriteFile.Textures.Count, savedSpriteFile.Textures.Count, "Texture counts do not match");
            Assert.AreEqual(spriteFile.Sprites.Count, savedSpriteFile.Sprites.Count, "Sprite counts do not match");

            for (int i = 0; i < spriteFile.Textures.Count; i++) {
                Assert.AreEqual(spriteFile.Textures[i].FileName, savedSpriteFile.Textures[i].FileName, "Texture file names values do not match");
                Assert.AreEqual(spriteFile.Textures[i].ColourKey, savedSpriteFile.Textures[i].ColourKey, "Texture colour key values do not match");
            }

            for (int i = 0; i < spriteFile.Sprites.Count; i++) {
                Assert.AreEqual(spriteFile.Sprites[i].Texture, savedSpriteFile.Sprites[i].Texture, "Sprite texture values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].X1, savedSpriteFile.Sprites[i].X1, "Sprite X1 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].Y1, savedSpriteFile.Sprites[i].Y1, "Sprite Y1 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].X2, savedSpriteFile.Sprites[i].X2, "Sprite X2 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].Y2, savedSpriteFile.Sprites[i].Y2, "Sprite Y2 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].ID, savedSpriteFile.Sprites[i].ID, "Sprite ID values do not match");
            }
        }
コード例 #2
0
ファイル: SpriteFileTests.cs プロジェクト: Jiwan/Revise
        public void TestLoadMethod()
        {
            const int TEXTURE_COUNT = 38;
            const int SPRITE_COUNT = 648;

            Stream stream = File.OpenRead(TEST_FILE);

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

            SpriteFile spriteFile = new SpriteFile();
            spriteFile.Load(stream);

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

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(TEXTURE_COUNT, spriteFile.Textures.Count, "Incorrect texture count");
            Assert.AreEqual(SPRITE_COUNT, spriteFile.Sprites.Count, "Incorrect sprite count");
        }
コード例 #3
0
ファイル: SpriteFileTests.cs プロジェクト: yuexiae/Revise
        public void TestSaveMethod()
        {
            SpriteFile spriteFile = new SpriteFile();

            spriteFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();

            spriteFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            SpriteFile savedSpriteFile = new SpriteFile();

            savedSpriteFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(spriteFile.Textures.Count, savedSpriteFile.Textures.Count, "Texture counts do not match");
            Assert.AreEqual(spriteFile.Sprites.Count, savedSpriteFile.Sprites.Count, "Sprite counts do not match");

            for (int i = 0; i < spriteFile.Textures.Count; i++)
            {
                Assert.AreEqual(spriteFile.Textures[i].FileName, savedSpriteFile.Textures[i].FileName, "Texture file names values do not match");
                Assert.AreEqual(spriteFile.Textures[i].ColourKey, savedSpriteFile.Textures[i].ColourKey, "Texture colour key values do not match");
            }

            for (int i = 0; i < spriteFile.Sprites.Count; i++)
            {
                Assert.AreEqual(spriteFile.Sprites[i].Texture, savedSpriteFile.Sprites[i].Texture, "Sprite texture values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].X1, savedSpriteFile.Sprites[i].X1, "Sprite X1 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].Y1, savedSpriteFile.Sprites[i].Y1, "Sprite Y1 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].X2, savedSpriteFile.Sprites[i].X2, "Sprite X2 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].Y2, savedSpriteFile.Sprites[i].Y2, "Sprite Y2 values do not match");
                Assert.AreEqual(spriteFile.Sprites[i].ID, savedSpriteFile.Sprites[i].ID, "Sprite ID values do not match");
            }
        }
コード例 #4
0
ファイル: SpriteFileTests.cs プロジェクト: yuexiae/Revise
        public void TestLoadMethod()
        {
            const int TEXTURE_COUNT = 38;
            const int SPRITE_COUNT  = 648;

            Stream stream = File.OpenRead(TEST_FILE);

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

            stream.Seek(0, SeekOrigin.Begin);

            SpriteFile spriteFile = new SpriteFile();

            spriteFile.Load(stream);

            long streamPosition = stream.Position;

            stream.Close();

            Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read");
            Assert.AreEqual(TEXTURE_COUNT, spriteFile.Textures.Count, "Incorrect texture count");
            Assert.AreEqual(SPRITE_COUNT, spriteFile.Sprites.Count, "Incorrect sprite count");
        }