private void ValidateSyntaxTree(NDjango.Interfaces.ITemplateManager manager) { ITemplate template = manager.GetTemplate(Template, new TestTyperesolver(), new NDjango.TypeResolver.ModelDescriptor(new NDjango.TypeResolver.IDjangoType[] { new NDjango.TypeResolver.CLRTypeDjangoType("Standard", typeof(EmptyClass)) })); //the same logic responsible for retriving nodes as in NodeProvider class (DjangoDesigner). List<INode> nodes = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll (node => (INode)node)).FindAll(node => (node is ICompletionValuesProvider) || (node.NodeType == NodeType.ParsingContext) || (node.ErrorMessage.Message != "")); List<DesignerData> actualResult = nodes.ConvertAll( node => { var value_provider = node as ICompletionValuesProvider; var values = value_provider == null ? new List<string>() : value_provider.Values; List<string> contextValues = new List<string>(values); if (node.NodeType == NodeType.ParsingContext) { contextValues.InsertRange(0 ,(node.Context.TagClosures)); return new DesignerData(node.Position, node.Length, contextValues.ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message); } else if (node.NodeType == NodeType.Reference) { return new DesignerData(node.Position, node.Length, GetModelValues(node.Context.Model, RecursionDepth).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message); } else return new DesignerData(node.Position, node.Length, new List<string>(values).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message); }); for (int i = 0; i < actualResult.Count; i++) { if (actualResult[i].Values.Length == 0) continue; Assert.AreEqual(ResultForDesigner[i].Length, actualResult[i].Length, "Invalid Length"); Assert.AreEqual(ResultForDesigner[i].Position, actualResult[i].Position, "Invalid Position"); Assert.AreEqual(ResultForDesigner[i].Severity, actualResult[i].Severity, "Invalid Severity"); Assert.AreEqual(ResultForDesigner[i].ErrorMessage, actualResult[i].ErrorMessage, "Invalid ErrorMessage"); Assert.AreEqual(ResultForDesigner[i].Values, actualResult[i].Values, "Invalid Values Array " + i); } }
private void ValidateSyntaxTree(NDjango.Interfaces.ITemplateManager manager) { ITemplate template = manager.GetTemplate(Template); //the same logic responsible for retriving nodes as in NodeProvider class (DjangoDesigner). List<INode> nodes = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll(node => (INode)node)); List<DesignerData> actualResult = nodes.ConvertAll( node => new DesignerData(node.Position, node.Length, new List<string>(node.Values).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message)); for (int i = 0; i < nodes.Count; i++) { Assert.AreEqual(actualResult[i].Length, ResultForDesigner[i].Length, "Invalid Length"); Assert.AreEqual(actualResult[i].Position, ResultForDesigner[i].Position, "Invalid Position"); Assert.AreEqual(actualResult[i].Severity, ResultForDesigner[i].Severity, "Invalid Severity"); Assert.AreEqual(actualResult[i].ErrorMessage, ResultForDesigner[i].ErrorMessage, "Invalid ErrorMessage"); Assert.AreEqual(actualResult[i].Values, ResultForDesigner[i].Values, "Invalid Values"); } }
public void AnalyzeBlockNameNode(NDjango.Interfaces.ITemplateManager manager) { ITemplate template = manager.GetTemplate(Template); INode bn_node = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll (node => (INode)node)).Find(node => node.NodeType == NodeType.BlockName); var value_provider = bn_node as ICompletionValuesProvider; var values = (value_provider == null) ? new List<string>() : value_provider.Values; List<string> blockNames = new List<string>(values); Assert.Greater(0, blockNames.Count(), "The dropdown with block names is empty"); foreach(string name in Result) Assert.Contains(name, blockNames, "Invalid block names list: there is no " + name); }
private void ValidateSyntaxTree(NDjango.Interfaces.ITemplateManager manager) { ITemplate template = manager.GetTemplate(Template); //the same logic responsible for retriving nodes as in NodeProvider class (DjangoDesigner). List<INode> nodes = GetNodes(template.Nodes.ToList<INodeImpl>().ConvertAll (node => (INode)node)).FindAll(node => (node.Values.ToList().Count != 0) || (node.NodeType == NodeType.ParsingContext) || (node.ErrorMessage.Message != "")); List<DesignerData> actualResult = nodes.ConvertAll( node => { List<string> contextValues = new List<string>(node.Values); if (node.NodeType == NodeType.ParsingContext) { contextValues.InsertRange(0 ,((ParserNodes.ParsingContextNode)node).Context.TagClosures); return new DesignerData(node.Position, node.Length, contextValues.ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message); } else return new DesignerData(node.Position, node.Length, new List<string>(node.Values).ToArray(), node.ErrorMessage.Severity, node.ErrorMessage.Message); }); for (int i = 0; i < actualResult.Count; i++) { if (actualResult[i].Values.Length == 0) continue; Assert.AreEqual(actualResult[i].Length, ResultForDesigner[i].Length, "Invalid Length"); Assert.AreEqual(actualResult[i].Position, ResultForDesigner[i].Position, "Invalid Position"); Assert.AreEqual(actualResult[i].Severity, ResultForDesigner[i].Severity, "Invalid Severity"); Assert.AreEqual(actualResult[i].ErrorMessage, ResultForDesigner[i].ErrorMessage, "Invalid ErrorMessage"); Assert.AreEqual(actualResult[i].Values, ResultForDesigner[i].Values, "Invalid Values"); } }