public void TestSaveMethod()
{
HeightmapFile heightmapFile = new HeightmapFile();
heightmapFile.Load(TEST_FILE);
MemoryStream savedStream = new MemoryStream();
heightmapFile.Save(savedStream);
heightmapFile.Load(TEST_FILE);
savedStream.Seek(0, SeekOrigin.Begin);
HeightmapFile savedHeightmapFile = new HeightmapFile();
savedHeightmapFile.Load(savedStream);
savedStream.Close();
for (int x = 0; x < heightmapFile.Height; x++) {
for (int y = 0; y < heightmapFile.Width; y++) {
Assert.AreEqual(heightmapFile[x, y], savedHeightmapFile[x, y], "Height values do not match");
}
}
for (int x = 0; x < heightmapFile.Patches.GetLength(0); x++) {
for (int y = 0; y < heightmapFile.Patches.GetLength(1); y++) {
Assert.AreEqual(heightmapFile.Patches[x, y].Minimum, savedHeightmapFile.Patches[x, y].Minimum, "Minimum patch values do not match");
Assert.AreEqual(heightmapFile.Patches[x, y].Maximum, savedHeightmapFile.Patches[x, y].Maximum, "Maximum patch values do not match");
}
}
for (int i = 0; i < heightmapFile.QuadPatches.Length; i++) {
Assert.AreEqual(heightmapFile.QuadPatches[i].Minimum, savedHeightmapFile.QuadPatches[i].Minimum, "Minimum quad patch values do not match");
Assert.AreEqual(heightmapFile.QuadPatches[i].Maximum, savedHeightmapFile.QuadPatches[i].Maximum, "Maximum quad patch values do not match");
}
}