示例#1
0
        public TResult HookCallback(
            Func <TInstance, TResult> originalFunction,
            TInstance instance)
        {
            var parameters = MocksaneParameters.Create();

            if (Instance != instance)
            {
                return(originalFunction(instance));
            }
            if (PredicateFunction != null && !PredicateFunction(parameters))
            {
                return(originalFunction(instance));
            }

            CallCount++;

            return(ReturnsFunction != null
                ? ReturnsFunction(parameters)
                : default);
        public void HookCallback(
            Action <TInstance> originalFunction,
            TInstance instance)
        {
            var parameters = MocksaneParameters.Create();

            if (Instance != instance)
            {
                originalFunction(instance);
                return;
            }

            if (PredicateFunction != null && !PredicateFunction(parameters))
            {
                originalFunction(instance);
                return;
            }

            CallCount++;
            CallbackFunction?.Invoke(parameters);
        }