/// <summary> /// Handler for the EngineController's AstBuilt event. /// Formats a string of AST for preview on the node. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void EngineController_AstBuilt(object sender, CompiledEventArgs e) { if (e.Node == nodeLogic.GUID) { var sb = new StringBuilder(); sb.AppendLine(string.Format("{0} AST:", e.Node)); foreach (var assocNode in e.AstNodes) { var pretty = assocNode.ToString(); //shorten the guids var strRegex = @"([0-9a-f-]{32}).*?"; var myRegex = new Regex(strRegex, RegexOptions.None); string strTargetString = assocNode.ToString(); foreach (Match myMatch in myRegex.Matches(strTargetString)) { if (myMatch.Success) { pretty = pretty.Replace(myMatch.Value, "..." + myMatch.Value.Substring(myMatch.Value.Length - 7)); } } sb.AppendLine(pretty); } ASTText = sb.ToString(); } }
public void TestInternalMigration() { //Arrange var guid = Guid.NewGuid(); var associativeNodes = new List <AssociativeNode> { new IntNode(1), new IntNode(2) }; var eventArgsCompiling = new CompilingEventArgs(guid); var eventArgsCompiled = new CompiledEventArgs(guid, associativeNodes); //Assert //Validates that the Guid values were stored correctly Assert.AreEqual(eventArgsCompiling.NodeId, guid); Assert.AreEqual(eventArgsCompiled.NodeId, guid); Assert.AreEqual((eventArgsCompiled.AstNodes as List <AssociativeNode>).Count, associativeNodes.Count); }