Esempio n. 1
0
        public bool Perform(Invocation invocation)
        {
            _callCount++;
            ProcessEventHandlers(invocation);
            foreach (IAction action in _actions)
            {
                action.Invoke(invocation);
            }

            //check that return value was set
            if (invocation.Result == Missing.Value && invocation.Method.ReturnType != typeof(void))
            {
                string message = string.Empty;

                if (invocation.IsPropertyGetAccessor)
                {
                    message = string.Format(
                        "An expectation match was found but the expectation was incomplete.  A return value for property '{0}' on '{1}' mock must be set.",
                        invocation.MethodName,
                        Receiver.MockName);
                }
                else if (invocation.IsMethod)
                {
                    message = string.Format(
                        "An expectation match was found but the expectation was incomplete.  A return value for method '{0}' on '{1}' mock must be set.",
                        invocation.MethodSignature,
                        Receiver.MockName);
                }

                var exception = new IncompleteExpectationException(message);

                throw exception;
            }
            return(true);
        }
Esempio n. 2
0
		public bool Perform(Invocation invocation)
		{
			_callCount++;
			ProcessEventHandlers(invocation);
			foreach (IAction action in _actions)
			{
				action.Invoke(invocation);
			}

			//check that return value was set
			if (invocation.Result == Missing.Value && invocation.Method.ReturnType != typeof(void))
			{
				string message = string.Empty;

				if (invocation.IsPropertyGetAccessor)
					message = string.Format(
						"An expectation match was found but the expectation was incomplete.  A return value for property '{0}' on '{1}' mock must be set.",
						invocation.MethodName,
						Receiver.MockName);
				else if (invocation.IsMethod)
					message = string.Format(
						"An expectation match was found but the expectation was incomplete.  A return value for method '{0}' on '{1}' mock must be set.",
						invocation.MethodSignature,
						Receiver.MockName);

				var exception = new IncompleteExpectationException(message);

				throw exception;
			}
			return true;
		}