Exemple #1
0
        public void OverrideMethods_BothMethodsMarked()
        {
            _selectionFactory.AddOptions(_options);
            _options.Parse(new[] { "--regex=(.*)" });
            MethodDefinition methodMain   = _assemblyDefinition.MainModule.Types[1].Methods[0];
            MethodDefinition methodModule = _assemblyDefinition.Modules[1].Types[1].Methods[0];

            _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(methodMain)).
            Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodMain.ReturnType));
            _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(methodModule)).
            Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodModule.ReturnType));

            _methodsVirtualizer.Transform(_tracker);

            _markingAttributeStrategy.AssertWasCalled(s => s.AddCustomAttribute(methodMain, _assemblyDefinition));
            _markingAttributeStrategy.AssertWasCalled(s => s.AddCustomAttribute(methodModule, _assemblyDefinition));
            _codeGenerator.AssertWasCalled(s => s.GenerateMethodAndMoveBody(methodModule));
            _codeGenerator.AssertWasCalled(s => s.GenerateMethodAndMoveBody(methodMain));
        }