public void TestCodeBlockToHooksGenerator_UNIT() { List <CodeBlock> blocks = PipelineComponentsFactory.GenerateTestCodeBlock(sourceFile); CodeblocksToHooksGenerator gen = new CodeblocksToHooksGenerator(); var hooksList = gen.GenerateHooks(blocks); Assert.IsTrue(hooksList.Count > 0); Assert.IsTrue(hooksList[1].Pairs[1].Key == 0); Assert.IsTrue(hooksList[1].Pairs[0].Value.Contains("var mrid = CodeHooks.Instance().OnMethodEnter(@\"ClassA.cs\", \"MethodA_1\");\n\n")); Assert.IsTrue(hooksList[1].Pairs[1].Value.Contains("CodeHooks.Instance().LogLineRun(mrid, 19")); }
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); }