public static void Handle(Invocation invocation, Mock mock) { if (mock.Behavior == MockBehavior.Strict) { throw MockException.NoSetup(invocation); } }
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); } }