public void WriteLevelToFile(TR2Level lvl, string filepath) { using (BinaryWriter writer = new BinaryWriter(File.Create(filepath))) { writer.Write(lvl.Serialize()); } }
public void Opera_ReadTest() { TR2LevelReader reader = new TR2LevelReader(); TR2Level lvl = reader.ReadLevel("opera.tr2"); byte[] lvlAsBytes = File.ReadAllBytes("opera.tr2"); //Does our view of the level match byte for byte? CollectionAssert.AreEqual(lvlAsBytes, lvl.Serialize(), "Read does not match byte for byte"); TR2LevelWriter writer = new TR2LevelWriter(); writer.WriteLevelToFile(lvl, "TEST.tr2"); byte[] copyAsBytes = File.ReadAllBytes("TEST.tr2"); //Does our saved copy match the original? CollectionAssert.AreEqual(lvlAsBytes, copyAsBytes, "Write does not match byte for byte"); }