Exemple #1
0
        public void Intercept(IInvocation invocation)
        {
            if (invocation.Method.IsAbstract)
            {
                _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
            }
            else if (invocation.Method.IsVirtual)
            {
                try
                {
                    var previousReturnValue = invocation.ReturnValue;

                    invocation.Proceed();

                    if (invocation.ReturnValue == previousReturnValue)
                    {
                        _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
                    }
                }
                catch (Exception)
                {
                    _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
                }
            }
        }
    public void Intercept(IInvocation invocation)
    {
        NSubstituteHacks.AssertIsNotInvokedDuringNSubstituteQuery(invocation, _instanceSource);

        if (invocation.Method.IsAbstract)
        {
            _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
        }
        else if (invocation.Method.IsVirtual)
        {
            try
            {
                var previousReturnValue = invocation.ReturnValue;

                invocation.Proceed();

                if (invocation.ReturnValue == previousReturnValue)
                {
                    _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
                }
            }
            catch (Exception)
            {
                _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
            }
        }
    }
Exemple #3
0
 public void Intercept(IInvocation invocation)
 {
     _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _trace);
 }
Exemple #4
0
 public void Intercept(IInvocation invocation)
 {
     NSubstituteHacks.AssertIsNotInvokedDuringNSubstituteQuery(invocation, _instanceSource);
     _cachedGeneration.SetupReturnValueFor(invocation, _instanceSource, _request);
 }