public void Import_ExportedLevel_SameLevel()
        {
            // Create simple levelstring.
            string levelString = "width=10\r\nheight=10\r\n";
            levelString += "start=0,1\r\nfinish=0,2\r\n";
            levelString += "1,2=tile\r\n4,4=ghost\r\n";

            // Import from levelstring to ILevel object.
            ILevelImporter importer = new LevelImporter(new StringReader(levelString));
            ILevel level = importer.ImportLevel();

            // Export from imported ILevel to string.
            StringWriter writer = new StringWriter();
            ILevelExporter exporter = new LevelExporter(writer);
            exporter.ExportLevel(level);

            // Levelstrings should be exactly the same.
            Assert.AreEqual(levelString, writer.LevelString);
        }
 /// <summary>
 /// Show a filedialog to save the level. An error will show if there
 /// is no level to save.
 /// </summary>
 private void SaveLevelDialog()
 {
     if (levelPanel.Level != null)
     {
         FileDialog dialog = new SaveFileDialog();
         dialog.AddExtension = true;
         dialog.Filter = "Level files (*.level)|*.level";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             ILevelExporter levelExporter = new LevelExporter(dialog.FileName);
             levelExporter.ExportLevel(levelPanel.Level);
         }
     }
     else
     {
         // No level to save.
         MessageBox.Show("There is nothing to save!", "Cannot save level",
             MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }