Exemplo n.º 1
0
        public void 例外ポイントカットを作成してcatch節の中にコードを追加する()
        {
            // オリジナルのソースコードのUCOとアスペクト合成後に期待されるソースコードのUCOを生成する
            var model  = UnifiedGenerators.GenerateProgramFromFile(_sourcePath);
            var actual = UnifiedGenerators.GenerateProgramFromFile(_expectationSourcePath);

            var pointcut = new Pointcut();

            pointcut.SetTarget("*");
            pointcut.SetTarget("Exception");


            // オリジナルのUCOに対して、アスペクトを合成する
            CodeProcessorProvider.WeavingBefore("exception", model, pointcut,
                                                UcoGenerator.CreateAdvice("Java", "System.out.println(\"test\");"));

            model.Normalize();

            var gen = UnifiedGenerators.GetCodeGeneratorByExtension(".java");

            Console.WriteLine(gen.Generate(model));
            Console.WriteLine(gen.Generate(actual));

            // 両者の構造を比較する
            Assert.That(model, Is.EqualTo(actual).Using(StructuralEqualityComparer.Instance));
        }
Exemplo n.º 2
0
//		[TestCase("Python", ".py", "print \"Inserted after.\"")]
        public void ExecutionAfterが正しく動作することを検証します(string language, string ext, string code)
        {
            var model = UnifiedGenerators.GenerateProgramFromFile(
                FixtureUtil.GetInputPath("Aspect", "Execution", "Fibonacci" + ext));
            var actual = UnifiedGenerators.GenerateProgramFromFile(
                FixtureUtil.GetInputPath("Aspect", "Execution", "Fibonacci_expectation_after" + ext));

            var pointcut = new Pointcut();

            pointcut.SetTarget("*");
            pointcut.SetTarget("fibonacci");

            CodeProcessorProvider.WeavingAfter("execution", model, pointcut, UcoGenerator.CreateAdvice(language, code));
            Assert.That(model,
                        Is.EqualTo(actual).Using(StructuralEqualityComparer.Instance));
        }