public void TestCodeAnalyzer_UNIT() { var sourceFileAnalyzer = new SourceFileAnalyzer(this.sourceFile); var blocks = sourceFileAnalyzer.GetCodeBlocks(); Assert.IsTrue(blocks.Count > 0); Assert.IsTrue(blocks[2].methodName == "GetCount"); Assert.IsTrue(blocks[0].methodName == "ClassA"); }
public void TestSetterInjection() { var source = PipelineComponentsFactory.GetSourceFileForFile("WithSetter.cs"); var sourceFileAnalyzer = new SourceFileAnalyzer(source); var blocks = sourceFileAnalyzer.GetCodeBlocks(); Assert.IsTrue(blocks.Count == 1); Assert.IsTrue(blocks[0].IsMethod); Assert.IsTrue(blocks[0].methodName.Equals("testSetter.set")); Assert.IsTrue(blocks[0].Statements.Count == 3); }
public void Test_INTEGRATION_ANALYSER_HOOKGENERATOR_RENDERER() { var sourceFileAnalyzer = new SourceFileAnalyzer(this.sourceFile); var blocks = sourceFileAnalyzer.GetCodeBlocks(); CodeblocksToHooksGenerator gen = new CodeblocksToHooksGenerator(); var hooksList = gen.GenerateHooks(blocks); HooksRenderer hooksRenderer = new HooksRenderer(); string outText = hooksRenderer.GetHookedCode(sourceFile, hooksList); Assert.IsTrue(outText.Contains("OnMethodEnter")); Assert.IsTrue(outText.Contains("using CodeRecordHelpers;")); File.WriteAllText("/tmp/code.cs", outText); }