public void Setup() { mocks = new MockRepository(); logger = new NullLogger(); typeResolver = mocks.DynamicMock<ITypeResolver>(); treeService = mocks.DynamicMock<ITreeCreationService>(); visitor = new ViewComponentVisitor(logger, typeResolver, treeService); }
public void Setup() { _mocks = new MockRepository(); _logger = new NullLogger(); _typeResolver = _mocks.DynamicMock <ITypeResolver>(); _treeService = _mocks.DynamicMock <ITreeCreationService>(); _visitor = new ViewComponentVisitor(_logger, _typeResolver, _treeService); }
public void Setup() { mocks = new MockRepository(); logger = new NullLogger(); typeResolver = mocks.DynamicMock <ITypeResolver>(); treeService = mocks.DynamicMock <ITreeCreationService>(); visitor = new ViewComponentVisitor(logger, typeResolver, treeService); }
public void CorrectSectionsCreated() { var grammar = new MarkupGrammar(ParserSettings.DefaultBehavior); var nodes = grammar.Nodes(new Position(new SourceContext( "<foo>1<tr>2<td>3</foo> <bar>4</td>5</tr>6</bar> stuff <baaz>yadda<baaz></baaz><quux><quux/></baaz>"))); var details = new ViewComponentDetailsAttribute("Testing") { Sections = "foo,baaz,bar,quux" }; var visitor = new ViewComponentVisitor(new ChunkBuilderVisitor(new VisitorContext{Paint=nodes.Rest.GetPaint()}), new ViewComponentInfo { Details = details }); visitor.Accept(nodes.Value); Assert.AreEqual(3, visitor.Sections.Count); Assert.AreEqual(1, visitor.Sections["foo"].Count); Assert.AreEqual("1<tr>2<td>3", ((SendLiteralChunk)visitor.Sections["foo"][0]).Text); }
public void CorrectSectionsCreated() { var grammar = new MarkupGrammar(ParserSettings.DefaultBehavior); var nodes = grammar.Nodes(new Position(new SourceContext( "<foo>1<tr>2<td>3</foo> <bar>4</td>5</tr>6</bar> stuff <baaz>yadda<baaz></baaz><quux><quux/></baaz>"))); var details = new ViewComponentDetailsAttribute("Testing") { Sections = "foo,baaz,bar,quux" }; var visitor = new ViewComponentVisitor(new ChunkBuilderVisitor(new VisitorContext { Paint = nodes.Rest.GetPaint() }), new ViewComponentInfo { Details = details }); visitor.Accept(nodes.Value); Assert.AreEqual(3, visitor.Sections.Count); Assert.AreEqual(1, visitor.Sections["foo"].Count); Assert.AreEqual("1<tr>2<td>3", ((SendLiteralChunk)visitor.Sections["foo"][0]).Text); }
public override bool Execute() { this.Log.LogMessage(MessageImportance.High, "OutputFile: {0}", this.OutputFile); this.Log.LogMessage(MessageImportance.High, "Namespace: {0}", this.Namespace); this.Log.LogMessage(MessageImportance.High, "ControllerSources: {0}", this.ControllerSources.Length); this.Log.LogMessage(MessageImportance.High, "ViewSources: {0}", this.ViewSources.Length); this.Log.LogMessage(MessageImportance.High, "ViewComponentSources: {0}", this.ViewComponentSources.Length); this.Log.LogMessage(MessageImportance.High, "Loading References..."); if (Debug) { System.Diagnostics.Debugger.Launch(); } foreach (ITaskItem reference in _assemblyReferences) { try { Assembly.LoadFrom(reference.ItemSpec); Log.LogMessage(MessageImportance.Low, "Loaded: {0}", reference.ItemSpec); } catch (Exception ex) { this.Log.LogMessage(MessageImportance.High, "Error loading reference: '{0}': {1}", reference.ItemSpec, ex.Message); } } if (File.Exists(this.OutputFile)) { File.Delete(this.OutputFile); } this.Log.LogMessage(MessageImportance.High, "Parsing Sources..."); foreach (ITaskItem ti in this.Sources) { string filePath = ti.GetMetadata("FullPath"); if (File.Exists(filePath)) { TypeInspectionVisitor visitor = new TypeInspectionVisitor(_typeResolver); _service.Parse(visitor, filePath); } } foreach (ITaskItem item in this.ViewComponentSources) { _typeResolver.Clear(); ViewComponentVisitor visitor = new ViewComponentVisitor(_logger, _typeResolver, _treeService); string filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(_sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (ITaskItem item in this.ControllerSources) { _typeResolver.Clear(); ControllerVisitor visitor = new ControllerVisitor(_logger, _typeResolver, _treeService); string filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(_sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (ITaskItem bi in this.ViewSources) { string filePath = bi.GetMetadata("FullPath"); _viewSourceMapper.AddViewSource(filePath); } this.Log.LogMessage(MessageImportance.High, "Generating {0}", this.OutputFile); Generator generator = new Generator(Namespace, OutputFile, ServiceTypeName, _logger, _naming, _source, _treeService); generator.Execute(); _generatedItems.Add(new TaskItem(this.OutputFile)); return(true); }
public override bool Execute() { Log.LogMessage(MessageImportance.High, "OutputFile: {0}", OutputFile); Log.LogMessage(MessageImportance.High, "Namespace: {0}", Namespace); Log.LogMessage(MessageImportance.High, "ControllerSources: {0}", ControllerSources.Length); Log.LogMessage(MessageImportance.High, "ViewSources: {0}", ViewSources.Length); Log.LogMessage(MessageImportance.High, "ViewComponentSources: {0}", ViewComponentSources.Length); Log.LogMessage(MessageImportance.High, "Loading References..."); if (Debug) { System.Diagnostics.Debugger.Launch(); } foreach (var reference in AssemblyReferences) { try { Assembly.LoadFrom(reference.ItemSpec); Log.LogMessage(MessageImportance.Low, "Loaded: {0}", reference.ItemSpec); } catch (Exception ex) { Log.LogMessage(MessageImportance.High, "Error loading reference: '{0}': {1}", reference.ItemSpec, ex.Message); } } if (File.Exists(OutputFile)) { File.Delete(OutputFile); } Log.LogMessage(MessageImportance.High, "Parsing Sources..."); foreach (var ti in Sources) { var filePath = ti.GetMetadata("FullPath"); if (File.Exists(filePath)) { var visitor = new TypeInspectionVisitor(typeResolver); service.Parse(visitor, filePath); } } foreach (var item in ViewComponentSources) { typeResolver.Clear(); var visitor = new ViewComponentVisitor(logger, typeResolver, treeService); var filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (var item in ControllerSources) { typeResolver.Clear(); var visitor = new ControllerVisitor(logger, typeResolver, treeService); var filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (var bi in ViewSources) { var filePath = bi.GetMetadata("FullPath"); viewSourceMapper.AddViewSource(filePath); } Log.LogMessage(MessageImportance.High, "Generating {0}", OutputFile); new Generator(Namespace, OutputFile, ServiceTypeName, logger, naming, source, treeService).Execute(); generatedItems.Add(new TaskItem(OutputFile)); return(true); }
public override bool Execute() { Log.LogMessage(MessageImportance.High, "OutputFile: {0}", OutputFile); Log.LogMessage(MessageImportance.High, "Namespace: {0}", Namespace); Log.LogMessage(MessageImportance.High, "ControllerSources: {0}", ControllerSources.Length); Log.LogMessage(MessageImportance.High, "ViewSources: {0}", ViewSources.Length); Log.LogMessage(MessageImportance.High, "ViewComponentSources: {0}", ViewComponentSources.Length); Log.LogMessage(MessageImportance.High, "Loading References..."); if (Debug) System.Diagnostics.Debugger.Launch(); foreach (var reference in AssemblyReferences) { try { Assembly.LoadFrom(reference.ItemSpec); Log.LogMessage(MessageImportance.Low, "Loaded: {0}", reference.ItemSpec); } catch (Exception ex) { Log.LogMessage(MessageImportance.High, "Error loading reference: '{0}': {1}", reference.ItemSpec, ex.Message); } } if (File.Exists(OutputFile)) File.Delete(OutputFile); Log.LogMessage(MessageImportance.High, "Parsing Sources..."); foreach (var ti in Sources) { var filePath = ti.GetMetadata("FullPath"); if (File.Exists(filePath)) { var visitor = new TypeInspectionVisitor(typeResolver); service.Parse(visitor, filePath); } } foreach (var item in ViewComponentSources) { typeResolver.Clear(); var visitor = new ViewComponentVisitor(logger, typeResolver, treeService); var filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (var item in ControllerSources) { typeResolver.Clear(); var visitor = new ControllerVisitor(logger, typeResolver, treeService); var filePath = item.GetMetadata("FullPath"); visitor.VisitCompilationUnit(sourceStorage.GetParsedSource(filePath).CompilationUnit, null); } foreach (var bi in ViewSources) { var filePath = bi.GetMetadata("FullPath"); viewSourceMapper.AddViewSource(filePath); } Log.LogMessage(MessageImportance.High, "Generating {0}", OutputFile); new Generator(Namespace, OutputFile, ServiceTypeName, logger, naming, source, treeService).Execute(); generatedItems.Add(new TaskItem(OutputFile)); return true; }