public void TestSaveMethod() { LevelOfDetailFile levelOfDetailFile = new LevelOfDetailFile(); levelOfDetailFile.Load(TEST_FILE); MemoryStream savedStream = new MemoryStream(); levelOfDetailFile.Save(savedStream); savedStream.Seek(0, SeekOrigin.Begin); LevelOfDetailFile savedLevelOfDetailFile = new LevelOfDetailFile(); savedLevelOfDetailFile.Load(savedStream); savedStream.Close(); Assert.AreEqual(levelOfDetailFile.Name, savedLevelOfDetailFile.Name, "Names do not match"); for (int x = 0; x < levelOfDetailFile.Height; x++) { for (int y = 0; y < levelOfDetailFile.Width; y++) { Assert.AreEqual(levelOfDetailFile[x, y], savedLevelOfDetailFile[x, y], "Values do not match"); } } }
public void TestLoadMethod() { const string NAME = "block_height"; Stream stream = File.OpenRead(TEST_FILE); stream.Seek(0, SeekOrigin.End); long fileSize = stream.Position; stream.Seek(0, SeekOrigin.Begin); LevelOfDetailFile levelOfDetailFile = new LevelOfDetailFile(); levelOfDetailFile.Load(stream); long streamPosition = stream.Position; stream.Close(); Assert.AreEqual(fileSize, streamPosition, "Not all of the file was read"); Assert.AreEqual(NAME, levelOfDetailFile.Name, "Incorrect name"); }