public void SetArgumentValue_sets_the_argument_value_of_the_invocation()
        {
            var invocation = A.Fake<IInvocation>();
            A.CallTo(() => invocation.Arguments).Returns(new object[] { });
            A.CallTo(() => invocation.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new CastleInvocationCallAdapter(invocation);

            adapter.SetArgumentValue(0, "test");

            A.CallTo(() => invocation.SetArgumentValue(0, "test")).MustHaveHappened();
        }
        public void CallBaseMethod_should_call_Proceed_on_invocation()
        {
            var invocation = A.Fake<IInvocation>();

            A.CallTo(() => invocation.Arguments).Returns(new object[] { });
            A.CallTo(() => invocation.Method).Returns(typeof(IFoo).GetMethod("Bar", new Type[] { }));

            var adapter = new CastleInvocationCallAdapter(invocation);

            adapter.CallBaseMethod();

            A.CallTo(() => invocation.Proceed()).MustHaveHappened();
        }
            public void Intercept(IInvocation invocation)
            {
                Guard.AgainstNull(invocation, nameof(invocation));

                if (invocation.Method.Equals(TagGetMethod))
                {
                    invocation.ReturnValue = this.tag;
                }
                else if (invocation.Method.Equals(TagSetMethod))
                {
                    this.tag = invocation.Arguments[0];
                }
                else
                {
                    var call = new CastleInvocationCallAdapter(invocation);
                    this.fakeCallProcessorProvider.Fetch(invocation.Proxy).Process(call);
                }
            }
 private void RaiseCallWasIntercepted(IInvocation invocation)
 {
     var handler = this.CallWasIntercepted;
     if (handler != null)
     {
         var call = new CastleInvocationCallAdapter(invocation);
         handler.Invoke(this, new CallInterceptedEventArgs(call));
     }
 }
 private void RaiseCallWasIntercepted(IInvocation invocation)
 {
     Logger.Debug("Call was intercepted: {0}.", invocation.Method);
     var handler = this.CallWasIntercepted;
     if (handler != null)
     {
         var call = new CastleInvocationCallAdapter(invocation);
         handler.Invoke(this, new CallInterceptedEventArgs(call));
     }
 }