示例#1
0
        public override InterceptionAction Handle(Invocation invocation, Mock mock)
        {
            var matchedSetup = mock.Setups.FindMatchFor(invocation);

            if (matchedSetup != null)
            {
                matchedSetup.Condition?.EvaluatedSuccessfully();

                if (matchedSetup.IsVerifiable)
                {
                    invocation.MarkAsMatchedByVerifiableSetup();
                }
                else
                {
                    invocation.MarkAsMatchedBySetup();
                }

                matchedSetup.SetOutParameters(invocation);

                // We first execute, as there may be a Throws
                // and therefore we might never get to the
                // next line.
                matchedSetup.Execute(invocation);
                return(InterceptionAction.Stop);
            }
            else if (mock.Behavior == MockBehavior.Strict)
            {
                throw MockException.NoSetup(invocation);
            }
            else
            {
                return(InterceptionAction.Continue);
            }
        }
示例#2
0
        public static bool Handle(Invocation invocation, Mock mock)
        {
            var matchedSetup = mock.Setups.FindMatchFor(invocation);

            if (matchedSetup != null)
            {
                matchedSetup.EvaluatedSuccessfully(invocation);

                if (matchedSetup.IsVerifiable)
                {
                    invocation.MarkAsMatchedByVerifiableSetup();
                }
                else
                {
                    invocation.MarkAsMatchedBySetup();
                }

                matchedSetup.SetOutParameters(invocation);

                // We first execute, as there may be a Throws
                // and therefore we might never get to the
                // next line.
                matchedSetup.Execute(invocation);
                return(true);
            }
            else
            {
                return(false);
            }
        }