Inheritance: IMethodReplacementProvider
        public void ShouldNotInvokeMethodBodyReplacementIfInterceptionIsDisabled()
        {
            var sampleInterceptor = new SampleInterceptor();
            var sampleProvider = new SampleMethodReplacementProvider(sampleInterceptor);

            Action<object> condition = (instance) =>
            {
                Assert.IsNotNull(instance);
                Assert.IsTrue(instance is IModifiableType);

                var modifiableType = (IModifiableType)instance;
                modifiableType.MethodBodyReplacementProvider = sampleProvider;
                modifiableType.IsInterceptionDisabled = true;

                instance.Invoke("DoSomething");
            };

            Test(condition);
            Assert.IsFalse(sampleInterceptor.HasBeenInvoked);
        }
        public void ShouldInvokeClassMethodReplacementProviderIfInterceptionIsEnabled()
        {
            Func<MethodReference, bool> methodFilter = m => m.Name == "DoSomething";
            var replacement = new SampleMethodReplacement();
            var provider = new SampleMethodReplacementProvider(replacement);

            MethodBodyReplacementProviderRegistry.SetProvider(provider);
            Action<Type> doTest = type =>
            {
                var doSomethingMethod = type.GetMethod("DoSomething");
                Assert.IsNotNull(doSomethingMethod);

                doSomethingMethod.Invoke(null, new object[0]);
            };

            Test("SampleLibrary.dll", "SampleStaticClassWithStaticMethod", methodFilter, doTest);
            Assert.IsTrue(replacement.HasBeenCalled);
        }