Ejemplo n.º 1
0
        public void Transforms_All_NoCtorsAvailable()
        {
            _checker.Stub(mock => mock.CanBeMixed(Arg <string> .Is.Anything)).Return(true);
            _tracker.Expect(tracker => tracker.GetAssemblies()).Return(new[] { _assemblyDefinition1 });
            _codeGenerator.Expect(generator => generator.CreateNewObjectMethod
                                      (_assemblyDefinition1, _assemblyDefinition1.MainModule.Types[1].Methods[0], _tracker));
            _codeGenerator.Expect(generator => generator.CreateNewObjectMethod
                                      (_assemblyDefinition1, _assemblyDefinition1.Modules[1].Types[1].Methods[0], _tracker));
            _tracker.Expect(tracker => tracker.GetAssemblies()).Return(new[] { _assemblyDefinition1 });
            _codeGenerator.Expect(generator => generator.ReplaceNewStatements
                                      (_assemblyDefinition1, _assemblyDefinition1.MainModule.Types[1], _assemblyDefinition1.MainModule.Types[1].Methods[0], _tracker)).Return(true);
            _tracker.Expect(tracker => tracker.MarkModified(_assemblyDefinition1));
            _codeGenerator.Expect(generator => generator.ReplaceNewStatements
                                      (_assemblyDefinition1, _assemblyDefinition1.Modules[1].Types[1], _assemblyDefinition1.Modules[1].Types[1].Methods[0], _tracker)).Return(true);
            _tracker.Expect(tracker => tracker.MarkModified(_assemblyDefinition1));

            _generator.Transform(_tracker);

            _tracker.VerifyAllExpectations();
        }
Ejemplo n.º 2
0
        public void OverrideMethods_MarksAssemblyWithMatchingMethodsModified()
        {
            _selectionFactory.AddOptions(_options);
            _options.Parse(new[] { "--regex=(.*)" });
            MethodDefinition methodMain = _assemblyDefinition.MainModule.Types[1].Methods[0];

            Assert.That(_tracker.IsModified(_assemblyDefinition), Is.False);
            _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(Arg <MethodDefinition> .Is.Anything)).
            Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodMain.ReturnType));
            _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(Arg <MethodDefinition> .Is.Anything)).
            Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodMain.ReturnType));

            _methodsVirtualizer.Transform(_tracker);

            Assert.That(_tracker.IsModified(_assemblyDefinition), Is.True);
        }