public void Init() { m_controller = new EditorController(); m_controller.ClearTree += m_controller_ClearTree; m_controller.BeginTreeUpdate += m_controller_BeginTreeUpdate; m_controller.EndTreeUpdate += m_controller_EndTreeUpdate; m_controller.AddedNode += m_controller_AddedNode; m_controller.UndoListUpdated += m_controller_UndoListUpdated; m_controller.RedoListUpdated += m_controller_RedoListUpdated; string tempFile = System.IO.Path.GetTempFileName(); ExtractResource("EditorControllerTests.test.aslx", tempFile); m_controller.Initialise(tempFile); DoExtraInitialisation(); try { System.IO.File.Delete(tempFile); } catch (System.IO.IOException) { // ignore } }
public void TestTemplates() { string folder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).Substring(6).Replace("/", @"\"); string templateFolder = System.IO.Path.Combine(folder, @"..\..\..\..\WorldModel\WorldModel\Core"); Dictionary<string, TemplateData> templates = EditorController.GetAvailableTemplates(templateFolder); List<string> tempFiles = new List<string>(); foreach (TemplateData template in templates.Values) { string tempFile = System.IO.Path.GetTempFileName(); EditorController.CreateNewGameFile(tempFile, template.Filename, "Test"); EditorController controller = new EditorController(); string errorsRaised = string.Empty; controller.ShowMessage += (object sender, TextAdventures.Quest.EditorController.ShowMessageEventArgs e) => { errorsRaised += e.Message; }; bool result = controller.Initialise(tempFile, templateFolder); Assert.IsTrue(result, string.Format("Initialisation failed for template '{0}': {1}", System.IO.Path.GetFileName(template.Filename), errorsRaised)); Assert.AreEqual(0, errorsRaised.Length, string.Format("Error loading game with template '{0}': {1}", System.IO.Path.GetFileName(template.Filename), errorsRaised)); tempFiles.Add(tempFile); } try { foreach (string tempFile in tempFiles) { System.IO.File.Delete(tempFile); } } catch { } }