예제 #1
0
        /**
         * Mock a non-void method. Called by generated mock instance classes, not directly by a developers
         * code.
         * @param mockInstance The mock object instance.
         * @param methodName The method for which to prepare a return value.
         * @param methodArgTypes The method argument types for which to prepare a return value.
         * @param methodArgValues The method argument values for which to prepare a return value.
         */
        public object mockNonVoidMethod(object mockInstance, string methodName, List <Type> methodArgTypes, List <object> methodArgValues)
        {
            fflib_QualifiedMethod  qm         = new fflib_QualifiedMethod(extractTypeName(mockInstance), methodName, methodArgTypes, mockInstance);
            fflib_MethodArgValues  argValues  = new fflib_MethodArgValues(methodArgValues);
            fflib_InvocationOnMock invocation = new fflib_InvocationOnMock(qm, argValues, mockInstance);

            if (Verifying)
            {
                verifyMethodCall(invocation);
            }
            else if (Stubbing)
            {
                fflib_MethodReturnValue methotReturnValue = prepareMethodReturnValue(invocation);
                if (DoThrowWhenExceptions != null)
                {
                    methotReturnValue.thenThrowMulti(DoThrowWhenExceptions);
                    DoThrowWhenExceptions = null;
                    return(null);
                }

                if (this.myAnswer != null)
                {
                    methotReturnValue.thenAnswer(this.myAnswer);
                    this.myAnswer = null;
                    return(null);
                }

                return(null);
            }
            else
            {
                recordMethod(invocation);
                return(returnValue(invocation));
            }

            return(null);
        }
예제 #2
0
 /**
  * Setup answer stubbing for a void method.
  * @param answer The answer to invoke.
  * @param mockInstance The mock object instance.
  */
 public object doAnswer(fflib_Answer answer, object mockInstance)
 {
     this.myAnswer = answer;
     return(mockInstance);
 }