static void ShowEditor() { DialogueBuilder editor = EditorWindow.GetWindow <DialogueBuilder>(); editor.Show(); Debug.Assert(editor != null, "there is no editor"); }
// Use this for initialization void Start() { json = GetComponent <JSON_Parser>(); dialogueBuilder = GetComponent <DialogueBuilder>(); stageEnded += dialogueBuilder.HandleStageEnd; scenarioList = json.LoadScenario(scenarioText); }
public void Test_GetIndentation() { var builder = new DialogueBuilder(); Assert.AreEqual(0, builder.GetIndentation("fff")); Assert.AreEqual(2, builder.GetIndentation(" fff")); Assert.AreEqual(4, builder.GetIndentation(" fff")); Assert.AreEqual(6, builder.GetIndentation(" fff")); }
public void BuildAndSerialize_NoYamlFiles() { var b = new DialogueBuilder(); var input = new FileInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll2.yaml")); File.WriteAllText(input.FullName, "#emptyfile"); Assert.Throws <NotSupportedException>(() => b.BuildAndSerialize(input)); }
/// <summary> /// /// <c>MainTest</c> /// /// Description: Runs the smoke test on the system as defined above /// -Ensures there exists valid scenes in build /// -For each scene, ensures that the scene can run without issues /// -Ensure all assets are capable of loading properly /// -Ensures Vital GUI components can be created and function properly /// -Ensures Language Engine can be created properly /// /// pre-condition: The build must have valid scenes /// /// post-condition: Smoke test successfully verified the system, or threw an error /// if the system is broken /// /// </summary> /// <returns>NULL</returns> public void MainTest() { Debug.Log("Smoketest Start"); // Get num scenes present in system build int numScenes = UnityEngine.SceneManagement.SceneManager.sceneCountInBuildSettings; Debug.Assert(numScenes > 0, "There aren't any main scenes in the build path"); Debug.Log("Num Scenes In Build: " + numScenes); //Declare variables for scene management string[] scenes = new string[numScenes]; Debug.Assert(scenes != null, "scenes initialization in smoketest is null"); // Get all build scene names for (int i = 0; i < numScenes; i++) { Debug.Assert(i < numScenes, "Smoketest Error: Index out of range"); scenes[i] = (UnityEngine.SceneManagement.SceneUtility.GetScenePathByBuildIndex(i)); Debug.Log("Scene Added: " + scenes[i]); } // Load scehes in editor-mode without threading Debug.Assert(scenes != null, "Passed in scenes parameter can't be null"); Debug.Assert(scenes.Length > 0, "Passed in scenes must have at least 1 scene object"); // Start Scenes in editor-mode. Load scene assets and ensure no crashes, exceptions, null references, or memory leaks happen Debug.Log("Loading Scenes in Editor Mode"); Array.ForEach(scenes, Scene => { EditorSceneManager.OpenScene(Scene); Debug.Log("Successfully loaded assets and tested " + Scene); }); // Processes Testing UsrInterface = ScriptableObject.CreateInstance <DialogueBuilder>(); Debug.Assert(UsrInterface.trees != null); Debug.Assert(UsrInterface.treeDialogues != null); Debug.Assert(UsrInterface.treesToDelete != null); Debug.Assert(UsrInterface.Dialogues != null); Debug.Assert(UsrInterface.NodeLayer != null); LEngine = new GameObject(); LEngine.AddComponent <LanguageEngine>(); Debug.Assert(LEngine.GetComponent <LanguageEngine>() != null); Debug.Log("Smoketest Finished"); }
public void cumstomGUI_TestSimplePasses() { // Creating variables for testing. Object[] nodes = Resources.LoadAll("DialogueTree/Tree1"); DialogueBuilder GUI = ScriptableObject.CreateInstance <DialogueBuilder>(); // Testing that relies on awake(). Debug.Assert(GUI.layers == 0, "failure to create found"); Debug.Assert(GUI.trees != null, "failure to create found"); Debug.Assert(GUI.treeDialogues != null, "failure to create treesDialogues"); Debug.Assert(GUI.treesToDelete != null, "failure to create treesToDelete"); Debug.Assert(GUI.atLayer != null, "failure to create atlayer"); Debug.Assert(GUI.Dialogues != null, "failure loading dialgoues"); Debug.Assert(GUI.NodeLayer != null, "failure to create nodeLayer"); Debug.Assert(GUI.dialwindows != null, "failure to create dialwindows"); Debug.Assert(GUI.responsewindows != null, "failure to create dialwindows"); }
public void TestSimpleTree() { string dialogue = @" Where you from stranger? Nowhere special I'm from little rock friend I've heard of that place, it's nice Wasn't when I was there Yeah it's nice enough I'm from quasar Your messing with me Maybe a bit Never lie to me kid No for real I do not believe you "; var builder = new DialogueBuilder(); var nodes = builder.Build(dialogue); Assert.AreEqual("Where you from stranger?", nodes[0].Body[0].Text); Assert.AreEqual("Nowhere special", nodes[0].Options[0].Text); Assert.AreEqual(null, nodes[0].Options[0].Destination); Assert.AreEqual("I'm from little rock friend", nodes[0].Options[1].Text); Assert.AreEqual(nodes[1].Identifier, nodes[0].Options[1].Destination); Assert.AreEqual("I've heard of that place, it's nice", nodes[1].Body[0].Text); Assert.AreEqual("Wasn't when I was there", nodes[1].Options[0].Text); Assert.AreEqual(null, nodes[1].Options[0].Destination); Assert.AreEqual("Yeah it's nice enough", nodes[1].Options[1].Text); Assert.AreEqual(null, nodes[1].Options[1].Destination); Assert.AreEqual("I'm from quasar", nodes[0].Options[2].Text); Assert.AreEqual(nodes[2].Identifier, nodes[0].Options[2].Destination); Assert.AreEqual("Your messing with me", nodes[2].Body[0].Text); Assert.AreEqual(nodes[3].Identifier, nodes[2].Options[0].Destination); Assert.AreEqual(nodes[4].Identifier, nodes[2].Options[1].Destination); Assert.AreEqual("Never lie to me kid", nodes[3].Body[0].Text); Assert.AreEqual("I do not believe you", nodes[4].Body[0].Text); Assert.IsEmpty(nodes[3].Options); Assert.IsEmpty(nodes[4].Options); }
public void TestSerialize() { string dlg = @" Where you from stranger? Nowhere special I'm from little rock friend I've heard of that place, it's nice Wasn't when I was there Yeah it's nice enough"; var builder = new DialogueBuilder(); var result = builder.BuildAndSerialize(dlg); StringAssert.Contains("Body:", result); StringAssert.Contains("- Text: I've heard of that place, it's nice", result); StringAssert.Contains("Options:", result); StringAssert.Contains("- Text: Wasn't when I was there", result); StringAssert.Contains("- Text: Yeah it's nice enough", result); }
public void BuildAndSerialize_OutputFileAlreadyExists() { var b = new DialogueBuilder(); var input = new FileInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.z")); File.WriteAllText(input.FullName, "#emptyfile"); var expectedOut = Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.dialogue.yaml"); if (File.Exists(expectedOut)) { File.Delete(expectedOut); } File.WriteAllText(expectedOut, "blahblah"); var ex = Assert.Throws <Exception>(() => b.BuildAndSerialize(input)); StringAssert.StartsWith("Output file path already exists", ex.Message); }
public void BuildAndSerialize_EmptyFile() { var b = new DialogueBuilder(); var input = new FileInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.z")); File.WriteAllText(input.FullName, "#emptyfile"); var expectedOut = Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.dialogue.yaml"); if (File.Exists(expectedOut)) { File.Delete(expectedOut); } var output = b.BuildAndSerialize(input); Assert.IsNull(output); Assert.IsFalse(File.Exists(expectedOut)); }
public void BuildAndSerialize_Success() { var b = new DialogueBuilder(); var input = new FileInfo(Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.z")); File.WriteAllText(input.FullName, "hey there wanderer"); var expectedOut = Path.Combine(TestContext.CurrentContext.WorkDirectory, "troll.dialogue.yaml"); if (File.Exists(expectedOut)) { File.Delete(expectedOut); } var output = b.BuildAndSerialize(input); Assert.AreEqual(expectedOut, output.FullName); StringAssert.Contains(@"- Text: hey there wanderer", File.ReadAllText(expectedOut)); }
static void Main(string[] args) { Parser.Default.ParseArguments<Options>(args) .WithParsed<Options>(o => { if(!string.IsNullOrWhiteSpace(o.CompileDialogue)) { var b = new DialogueBuilder(); try { var result = b.BuildAndSerialize(new FileInfo(o.CompileDialogue)); if(result == null) Console.WriteLine("No file created"); else Console.WriteLine("Created " + result.FullName); } catch(Exception ex) { Console.WriteLine(ex.Message); } return; } var f = new WorldFactory(); if(o.ResourcesDirectory != null) f.ResourcesDirectory = o.ResourcesDirectory; if (o.Validate) { var validator = new WorldValidator(); validator.IncludeStackTraces = o.StackTraces; validator.Validate(f); if(validator.Warnings.Length > 0) { Console.WriteLine("WARNINGS:"); Console.WriteLine(validator.Warnings); } if(validator.Errors.Length > 0) { Console.WriteLine("ERRORS:"); Console.WriteLine(validator.Errors); } Console.WriteLine("Finished Validation:"); Console.WriteLine(validator.ErrorCount + " Errors"); Console.WriteLine(validator.WarningCount + " Warnings"); } else { //Don't log to the console when Console Gui is running LogManager.Configuration.RemoveTarget("logconsole"); Application.Init(); var mainWindow = new MainWindow(f); Application.Top.Add(mainWindow); Application.Run(); } }); }
public void BuildAndSerialize_NoFile() { var b = new DialogueBuilder(); Assert.Throws <FileNotFoundException>(() => b.BuildAndSerialize(new FileInfo("troll"))); }